I'm trying to read a .txt DataGridView in VB Express 2010 and search for contents. How do I do it? (content is relevant) - vb.net

This is my first time on this site and I would like help very much.
I made a program in VB 2010 Express to try and read a .txt file into an DataGridView. I got it to read in and I have a function to search through surnames and search through date of birth. The way I want it to search is so that if I type in the month (02) for February, then it will list all the people with the DOB month as February. The surnames work fine but the DOB doesn't. Whenever I try to search the month February (02) The DataGridView becomes blank. http://puu.sh/8asUD.png (picture of addressgrid/datagridview going blank) The contents of the .txt file are exactly:
Jackson,Samantha,2 Heather Row,Basingstoke,RG21 3SD,01256 135434,23/04/1973,sam.jackson#hotmail.com,Vickers,Jonathan,18 Saville Gardens,Reading,RG3 5FH,01196 678254,04/02/1965,the_man#btinternet.com,Morris,Sally,The Old Lodge, Hook,RG23 5RD,01256 728443,19/02/1975,smorris#fgh.co.uk,Cobbly,Harry,345 The High Street,Guildford,GU2 4KJ,01458 288763,30/03/1960,harry.cobbly#somewhere.org.uk,Khan,Jasmine,36 Hever Avenue,Edenbridge,TN34 4FG,01569 276524,28/02/1980,jas.khan#hotmail.com,Vickers,Harriet,45 Sage Gardens,Brighton,BN3 2FG,01675 662554,04/04/1968,harriet.vickers#btinternet.com
Here's the code for THE ENTIRE FORM:
Public Class AddressBook
Structure Address
Public Forename As String
Public Surname As String
Public Address1 As String
Public Address2 As String
Public Postcode As String
Public Phonenumber As String
Public DOB As String
Public Email As String
End Structure
Public Addressbook(40) As Address
Public recordcounter As Integer = 0
Public readfile As Boolean = False
Private Sub btt_read_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btt_read.Click
'Declare Textfile
If System.IO.File.Exists("addressbook.txt") = False Then
MsgBox("This text file doesn't exist")
End If
Dim Addressfile As New System.IO.StreamReader("C:\Users\DirtyMike\Desktop\123\Controlled Assessment\addressbook.txt", True)
Dim loopcounter As Integer
Dim filecontent As String
Dim temparray() As String
If readfile = False Then
filecontent = Addressfile.ReadLine
temparray = filecontent.Split(",")
readfile = True
'Display the data
For loopcounter = 0 To (temparray.Length - 7) Step 8
Addressbook(recordcounter).Surname = temparray(loopcounter + 0)
Addressbook(recordcounter).Forename = temparray(loopcounter + 1)
Addressbook(recordcounter).Address1 = temparray(loopcounter + 2)
Addressbook(recordcounter).Address2 = temparray(loopcounter + 3)
Addressbook(recordcounter).Postcode = temparray(loopcounter + 4)
Addressbook(recordcounter).Phonenumber = temparray(loopcounter + 5)
Addressbook(recordcounter).DOB = temparray(loopcounter + 6)
Addressbook(recordcounter).Email = temparray(loopcounter + 7)
recordcounter = recordcounter + 1
Next
Addressfile.Close()
REM Display the Data
For loopcounter = 0 To recordcounter - 1
AddressGrid.Rows.Add()
AddressGrid.Rows.Item(loopcounter).Cells(0).Value = Addressbook(loopcounter).Surname
AddressGrid.Rows.Item(loopcounter).Cells(1).Value = Addressbook(loopcounter).Forename
AddressGrid.Rows.Item(loopcounter).Cells(2).Value = Addressbook(loopcounter).Address1
AddressGrid.Rows.Item(loopcounter).Cells(3).Value = Addressbook(loopcounter).Address2
AddressGrid.Rows.Item(loopcounter).Cells(6).Value = Addressbook(loopcounter).DOB
AddressGrid.Rows.Item(loopcounter).Cells(7).Value = Addressbook(loopcounter).Email
AddressGrid.Rows.Item(loopcounter).Cells(5).Value = Addressbook(loopcounter).Phonenumber
AddressGrid.Rows.Item(loopcounter).Cells(4).Value = Addressbook(loopcounter).Postcode
Next
'Display the data from the file.
End If
End Sub
Private Sub bttsurname_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btt_searchsur.Click
AddressGrid.Rows.Clear()
Dim surname As String
Dim loopcounter As Integer
Dim positioncounter As Integer
surname = txt_surname.Text
For loopcounter = 0 To recordcounter
If Addressbook(loopcounter).Surname = surname Then
Me.AddressGrid.Rows.Add()
Me.AddressGrid.Rows.Item(positioncounter).Cells(0).Value = Me.Addressbook(loopcounter).Surname
Me.AddressGrid.Rows.Item(positioncounter).Cells(1).Value = Me.Addressbook(loopcounter).Forename
Me.AddressGrid.Rows.Item(positioncounter).Cells(2).Value = Me.Addressbook(loopcounter).Address1
Me.AddressGrid.Rows.Item(positioncounter).Cells(3).Value = Me.Addressbook(loopcounter).Address2
Me.AddressGrid.Rows.Item(positioncounter).Cells(4).Value = Me.Addressbook(loopcounter).Postcode
Me.AddressGrid.Rows.Item(positioncounter).Cells(5).Value = Me.Addressbook(loopcounter).Phonenumber
Me.AddressGrid.Rows.Item(positioncounter).Cells(6).Value = Me.Addressbook(loopcounter).DOB
Me.AddressGrid.Rows.Item(positioncounter).Cells(7).Value = Me.Addressbook(loopcounter).Email
positioncounter = positioncounter + 1
End If
Next
End Sub
Private Sub btt_menu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btt_menu.Click
Menu1.Show()
Me.Close()
End Sub
Private Sub btt_searchdob_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btt_searchdob.Click
AddressGrid.Rows.Clear()
Dim DOB As String
Dim loopcounter, positioncounter As Integer
Dim MonthA As String
DOB = txt_DOB.Text
MonthA = Mid(DOB, 4, 2)
positioncounter = 0
For loopcounter = 0 To recordcounter
If MonthA = Mid(Addressbook(loopcounter).DOB, 4, 2) Then
Me.AddressGrid.Rows.Add()
Me.AddressGrid.Rows.Item(positioncounter).Cells(0).Value = Me.Addressbook(loopcounter).Surname
Me.AddressGrid.Rows.Item(positioncounter).Cells(1).Value = Me.Addressbook(loopcounter).Forename
Me.AddressGrid.Rows.Item(positioncounter).Cells(2).Value = Me.Addressbook(loopcounter).Address1
Me.AddressGrid.Rows.Item(positioncounter).Cells(3).Value = Me.Addressbook(loopcounter).Address2
Me.AddressGrid.Rows.Item(positioncounter).Cells(4).Value = Me.Addressbook(loopcounter).Postcode
Me.AddressGrid.Rows.Item(positioncounter).Cells(5).Value = Me.Addressbook(loopcounter).Phonenumber
Me.AddressGrid.Rows.Item(positioncounter).Cells(6).Value = Me.Addressbook(loopcounter).DOB
Me.AddressGrid.Rows.Item(positioncounter).Cells(7).Value = Me.Addressbook(loopcounter).Email
positioncounter = positioncounter + 1
End If
Next
End Sub
Private Sub btt_clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btt_clear.Click
AddressGrid.Rows.Clear()
For loopcounter = 0 To recordcounter - 1
AddressGrid.Rows.Add()
AddressGrid.Rows.Item(loopcounter).Cells(0).Value = Addressbook(loopcounter).Surname
AddressGrid.Rows.Item(loopcounter).Cells(1).Value = Addressbook(loopcounter).Forename
AddressGrid.Rows.Item(loopcounter).Cells(2).Value = Addressbook(loopcounter).Address1
AddressGrid.Rows.Item(loopcounter).Cells(3).Value = Addressbook(loopcounter).Address2
AddressGrid.Rows.Item(loopcounter).Cells(4).Value = Addressbook(loopcounter).Postcode
AddressGrid.Rows.Item(loopcounter).Cells(5).Value = Addressbook(loopcounter).Phonenumber
AddressGrid.Rows.Item(loopcounter).Cells(6).Value = Addressbook(loopcounter).DOB
AddressGrid.Rows.Item(loopcounter).Cells(7).Value = Addressbook(loopcounter).Email
Next
'Display the data from the file.
End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Any help would be greatly appreciated. Thanks in advance! (P.S. Apologies for the poor tags, they're probably wrong.)

If you can add some Symbol into the text this process will be easy to fetch Like:
TextFileData = %Your Name,Age,Address%Other Name, Other Age, Other Address,
You can use split ("%") to get the users information
Users = TextFileData.Split("%")
Then use split(",") to extract the information
Information = Users(0),Split(",")

Related

How make pagination next and previous button in VB.NET for Acces database

I am currently using a FlowLayoutPanel1 and UserControl1.vb to show me data from a database in Access.
I need 10 results to appear each time I hit the next button or the previous button.
This is my code:
Dim CLIENTES_GUARDADOS() As pedidos
Public Sub LISTAS_CLIENTES()
COMANDOS.Parameters.Clear()
CONECTAR.Close()
CONECTAR.Open()
COMANDOS.CommandText = "SELECT Count(PEDIDOS_CLIENTES.ID) AS Total FROM PEDIDOS_CLIENTES"
LEER = COMANDOS.ExecuteReader
LEER.Read()
Dim count As Integer = LEER(0)
ReDim CLIENTES_GUARDADOS(count)
CONECTAR.Close()
CONECTAR.Open()
COMANDOS.CommandText = "SELECT TOP 100 * FROM PEDIDOS_CLIENTES Order By ID DESC"
LEER = COMANDOS.ExecuteReader
FlowLayoutPanel5.Controls.Clear()
Dim i As Integer = 0
While LEER.Read() = True
CLIENTES_GUARDADOS(i) = New pedidos()
CLIENTES_GUARDADOS(i).ID = LEER("ID")
CLIENTES_GUARDADOS(i).nombre.Text = LEER("NOMBRE")
CLIENTES_GUARDADOS(i).NOMBRE_001 = LEER("NOMBRE")
CLIENTES_GUARDADOS(i).APELLIDO_001 = LEER("APELLIDO")
CLIENTES_GUARDADOS(i).APELLIDO.Text = LEER("APELLIDO")
CLIENTES_GUARDADOS(i).TELEFONO_001 = LEER("TELEFONO")
CLIENTES_GUARDADOS(i).PEDIDO = LEER("PEDIDO")
CLIENTES_GUARDADOS(i).CANTIDAD = LEER("CANTIDAD")
CLIENTES_GUARDADOS(i).COSTO = LEER("COSTO")
CLIENTES_GUARDADOS(i).ADELANTO = LEER("ADELANTO")
CLIENTES_GUARDADOS(i).FALTA = LEER("FALTA")
CLIENTES_GUARDADOS(i).ESTADO_003 = LEER("ESTADO")
CLIENTES_GUARDADOS(i).ESTADO_001.Text = LEER("ESTADO")
CLIENTES_GUARDADOS(i).PAGADO = LEER("PAGADO")
CLIENTES_GUARDADOS(i).FECHA = LEER("FECHA")
CLIENTES_GUARDADOS(i).METODO_DE_PAGO.Text = LEER("FECHA")
CLIENTES_GUARDADOS(i).HORA = LEER("HORA")
FlowLayoutPanel5.Controls.Add(CLIENTES_GUARDADOS(i))
i += 1
End While
CONECTAR.Close()
Me.Refresh()
End Sub
Try following :
Public Class Form1
Dim CLIENTES_GUARDADOS()
Dim index As Integer = 0
Private Sub ButtonNext_Click(sender As System.Object, e As System.EventArgs) Handles ButtonNext.Click
If index < CLIENTES_GUARDADOS.Length - 2 Then
index = index + 1
DisplayCurrent()
End If
End Sub
Private Sub ButtonPrevious_Click(sender As System.Object, e As System.EventArgs) Handles ButtonPrevious.Click
If index > 0 Then
index = index - 1
DisplayCurrent()
End If
End Sub
Private Sub DisplayCurrent()
'fill panel with the CLIENTES_GUARDADOS(index)
End Sub
End Class

how to count the number of check boxes checked in visual basic?

Private Sub Btn_Cast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Cast.Click
Dim Counter As Integer = 0
If ChkBox_Barton.CheckState = 1 And ChkBox_Martin.CheckState = 1 And ChkBox_Richards.CheckState = 1 Then
MsgBox("Don't vote for more than 2")
End If
Dim Count_Barton As Integer
Dim Count_Martin As Integer
Dim Count_Richards As Integer
If ChkBox_Barton.Checked Then Count_Barton += 1
If ChkBox_Martin.Checked = 1 Then Count_Martin += 1
If ChkBox_Richards.CheckState = 1 Then Count_Richards += 1
End Sub
Problem is, I'm trying to count it everytime, then let it reset and count again.
Example. I select Barton one time, click vote, then i should be able to select someone new and click vote and it should keep counting.
what can I do?
I need to then display my results. Should I just hold the number in a text or Integer file then display it that way?
I quickly set up your application myself.
Following Code applies to this GUI:
Code:
Public Class VoteCounter
Dim intCountBarton As Integer
Dim intCountMartin As Integer
Dim intCountRichards As Integer
Private Sub ButtonVote_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonVote.Click
If CheckBoxBarton.CheckState = 1 And CheckBoxMartin.CheckState = 1 And CheckBoxRichards.CheckState = 1 Then
MsgBox("Don't vote for more than 2")
CheckBoxBarton.Checked = False
CheckBoxMartin.Checked = False
CheckBoxRichards.Checked = False
End If
If CheckBoxBarton.Checked Then
intCountBarton += 1
End If
If CheckBoxMartin.Checked Then
intCountMartin = intCountMartin + 1
End If
If CheckBoxRichards.Checked Then
intCountRichards = intCountRichards + 1
End If
CheckBoxBarton.Checked = False
CheckBoxMartin.Checked = False
CheckBoxRichards.Checked = False
End Sub
Private Sub ButtonResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonResult.Click
MsgBox("Barton: " & intCountBarton & vbNewLine & "Martin: " & intCountMartin & vbNewLine & "Richards: " & intCountRichards)
End Sub
Private Sub ButtonReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonReset.Click
CheckBoxBarton.Checked = False
CheckBoxMartin.Checked = False
CheckBoxRichards.Checked = False
intCountBarton = 0
intCountMartin = 0
intCountRichards = 0
End Sub
End Class
Dim Count_Barton As Integer = 0
Dim Count_Martin As Integer = 0
Dim Count_Richards As Integer = 0
Private Sub Btn_Cast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Cast.Click
Dim Counter As Integer = 0 'NOT SURE WHAT THIS IS DOING... NOT BEING USED
If ChkBox_Barton.CheckState = 1 And ChkBox_Martin.CheckState = 1 And ChkBox_Richards.CheckState = 1 Then
MsgBox("Don't vote for more than 2")
Else
If ChkBox_Barton.Checked Then Count_Barton += 1
If ChkBox_Martin.Checked = 1 Then Count_Martin += 1
If ChkBox_Richards.CheckState = 1 Then Count_Richards += 1
End If
End Sub

How to search a text file in Visual basic

So my teacher wants the class to search a file for an authors name and display all the info on that author in a text box like a mailing label.
Here is my code i added a picture below. I'm really lost as to getting the program to take the Authors string and search another file. I can display the Authors name prefectly but how do you search another file for that name and display the information on that line about the author?
Imports System.IO
Public Class Form1
' CSCI 6
' Alex Smutny
' Lab #3
'
' DATE: 3/1/2013
Dim SR As IO.StreamReader
' initial start spot for the record Count
Dim RecordCount As Integer = 0
Dim Author As String = File.ReadAllText("Authors.txt")
Private Sub btnQuit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles quitBtn.Click
' Properly Exits the application.
Me.Close()
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles closeBtn.Click
readBtn.Text = "Read"
SR.Close()
' Changes the button statuses Locked or unlocked and sets default settings.
openBtn.Enabled = True
quitBtn.Enabled = True
readBtn.Enabled = False
closeBtn.Enabled = False
SearBtn.Enabled = False
RecordCount = 0
recordNum.Clear()
bookNum.Clear()
isbnNum.Clear()
bookTitle.Clear()
authorName.Clear()
bookPrice.Clear()
bookQuanity.Clear()
reorderPoint.Clear()
End Sub
Private Sub btnOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles openBtn.Click
' Sets the file to read from and opens it.
SR = IO.File.OpenText("Books.Txt")
' Changes the status of the buttons again now that the File is open and ready to read.
openBtn.Enabled = False
quitBtn.Enabled = False
readBtn.Enabled = True
closeBtn.Enabled = True
SearBtn.Enabled = True
End Sub
Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles readBtn.Click
'Changes the Read button to say next because it makes more since.
readBtn.Text = "Next"
' Setting all the variables.
Dim srIndex1 As Integer = 18
Dim srTitle As Integer
Dim srAuthor As Integer
Dim srPrice As Integer
Dim srDPrice As Double
Dim srData As String
Dim srLength As Integer
If SR.Peek() = -1 Then
MessageBox.Show("End of file")
Else
' Starts to read
srData = SR.ReadLine
' Increment counter by 1.
RecordCount = RecordCount + 1
' Determine the record length.
srLength = srData.Length
' gets the book number
bookNum.Text = srData.Substring(0, 3)
' ISBN number
isbnNum.Text = srData.Substring(4, 13)
' Book title
For srTitle = 1 To srLength Step 1
If srData.Substring(srIndex1 + srTitle, 1) = "," Then
bookTitle.Text = srData.Substring(srIndex1, srTitle)
srIndex1 = srIndex1 + srTitle + 1
srTitle = srLength + 1
End If
Next
' Book Author
For srAuthor = 1 To srLength Step 1
If srData.Substring(srIndex1 + srAuthor, 1) = "," Then
authorName.Text = srData.Substring(srIndex1, srAuthor)
srIndex1 = srIndex1 + srAuthor + 1
srAuthor = srLength + 1
Author = authorName.Text
End If
Next
' Book Price
For srPrice = 1 To srLength Step 1
If srData.Substring(srIndex1 + srPrice, 1) = "," Then
srDPrice = CDbl(srData.Substring(srIndex1, srPrice))
bookPrice.Text = srDPrice.ToString("C")
srIndex1 = srIndex1 + srPrice + 1
srPrice = srLength + 1
End If
Next
' Quanity
bookQuanity.Text = srData.Substring(srIndex1, 2)
srIndex1 = srIndex1 + 3
' Reorder Point
reorderPoint.Text = srData.Substring(srIndex1, 2)
End If
' record count
recordNum.Text = RecordCount
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
openBtn.Enabled = True
quitBtn.Enabled = True
readBtn.Enabled = False
closeBtn.Enabled = False
SearBtn.Enabled = False
End Sub
Private Sub SearBtn_Click(sender As System.Object, e As System.EventArgs) Handles SearBtn.Click
SR = IO.File.OpenText("Authors.Txt")
SR.Close()
readBtn.Text = "Restart"
RecordCount = 0
SR = IO.File.OpenText("Books.Txt")
End Sub
End Class
Authors File http://pastebin.com/t7C8ye9e
Books File http://pastebin.com/y6DNyUFd
So my goal is to just get the info for the current author and then get it from the other file and take out all trailing spaces and just display it as a mailing label.
There's a variety of good ways to do this. Let's, for now, assume that there's one author per line. If there is, you can get the entire string with My.Computer.FileSystem.ReadAllText() and use String.Split(Environment.NewLine) to split it on each new line. At any rate, you need to have some way to separate each author in the list. String.Split returns an array of String objects. You can then iterate through the array to determine if a term matches the search. Here's an example of a for loop.
'... search term given in param
'... after loading text file
Dim StrArr() As String
StrArr = AuthorsString.Split(Environment.NewLine)
Dim i as Integer
For i=0 to StrArr.Length - 1 Step 1
If StrArr(i).toLower = SearchTerm.toLower Then
'String is a match! Case insensitivity should make it a little easier for the user.
End If
Next
Let me know if you have any questions.

VB.NET File Explorer

I'm making a File Explorer in VB.NET. Everything is going fine except one thing. When you click the dynamically created label to "open" a folder, I need to get the value of the label (so I can set a variable to it.) I can't get the value because the label was dynamically create. Therefore the object doesn't exist. Here's my code:
Imports System.IO
Public Class Form1
Dim Path As String
Dim FolderCount = 0
Dim FolderWidth = 128
Dim FolderHeight = 128
Dim WidthAndPadding = FolderWidth + 10
Dim HeightAndPadding = FolderHeight + 10
Dim FolderTitle As String
Dim CombinedWidth
Dim FolderRows = 0
Dim OnNewLine = False
Dim FolderTop = 0
Dim FolderLeft = 0
Dim FullPath
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.AutoScroll = True
Path = "C:\Program Files\"
For Each Dir As String In Directory.GetDirectories(Path)
CreateFolders(Dir)
Next
End Sub
Public Sub CreateFolders(ByVal StrDirectory)
FolderTitle = StrDirectory.Substring(Path.Length)
Dim Folder As New Label
FolderLeft = WidthAndPadding * FolderCount
Folder.Left = FolderLeft
Folder.Top = FolderTop
Folder.Width = FolderWidth
Folder.Height = FolderHeight
Folder.Image = My.Resources.Folder
Folder.TextAlign = ContentAlignment.BottomCenter
If FolderTitle.Length > 15 Then
FolderTitle = FolderTitle.Substring(0, 15) + "..."
End If
Folder.Text = FolderTitle
Folder.Font = New Font("Arial", 9.5)
FolderCount += 1
CombinedWidth = FolderCount * WidthAndPadding
If CombinedWidth >= Me.Width Then
OnNewLine = False
If OnNewLine = False Then
FolderRows = FolderRows + 1
FolderCount = 0
CombinedWidth = 0
Folder.Left = FolderCount * FolderWidth
FolderTop = FolderRows * FolderHeight
Folder.Top = FolderTop
OnNewLine = True
'FolderCount += 1
End If
End If
Me.Controls.Add(Folder)
AddHandler Folder.DoubleClick, AddressOf Folder_DoubleClick
FullPath = Path + FolderTitle
End Sub
Private Sub Folder_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
'MsgBox(Folder.Text)
End Sub
End Class
The event handler's sender parameter contains the label that generated the event.
You can cast it back to Label by writing CType(sender, Label).

Getting Images From file and Adding them to Array

I'm trying to create a program that checks if someone is going to Happy Hour. If not, it lists those who aren't and puts their picture next to their name.
I'm able to achieve all but get the images locally and store them in an array (which would be added to pictureArray(i)).
(You can see the commented out sections are where I've tried to get the images...)
Any ideas?
Public Class Form1
Dim ITLPList() As String = {"Name 1", "Name 2", "Name 3", "Name 4", "Name 5", "Name 6"}
' Dim imageList As New ImageList
' Dim fileSteam As New System.IO.FileStream(sFileName, System.IO.FileMode.Open)
' Dim img As Image
' Dim sFileName As String = "C:\Users\turcotd\Desktop\ITLPers\itlp1.jpg"
Dim itlpTally() As String
Dim labelArray(5) As Label
Dim pictureArray(5) As PictureBox
Dim intTally As Integer
Dim i As Integer = 0
Public itlpIndex As Integer = 0
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
itlpName.Text = ITLPList(0)
labelArray(0) = lblPerson0
labelArray(1) = lblPerson1
labelArray(2) = lblPerson2
labelArray(3) = lblPerson3
labelArray(4) = lblPerson4
pictureArray(0) = picITLP0
pictureArray(1) = picITLP1
pictureArray(2) = picITLP2
pictureArray(3) = picITLP3
pictureArray(4) = picITLP4
End Sub
Private Sub btnYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click
If (i < 6) Then
itlpName.Text = ITLPList(i)
i = i + 1
End If
End Sub
Private Sub btnNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNo.Click
If (i < 6) Then
'Names
itlpName.Text = ITLPList(i)
intTally = intTally + 1
lblTally.Text = intTally
labelArray(i).Text = ITLPList(i)
'Images
' img = Image.FromStream(fileSteam)
' fileSteam.Close()
' imageList.Images.Add(img)
' pictureArray(i).Image = imageList.Images.Item(0)
' img.Dispose()
' img = Image.FromFile(sFileName)
i = i + 1
End If
itlpName.Text = ITLPList(i)
End Sub
End Class
You could get all jpg's in a directory as FileInfo in the following way:
Dim dir = New IO.DirectoryInfo("C:\Users\turcotd\Desktop\ITLPers")
Dim images = dir.GetFiles("*.jpg", IO.SearchOption.AllDirectories).ToList
Loading the file into the PictureBox from a file is a very straightforward operation:
picITLP0.Image = Image.FromFile("C:\Users\turcotd\Desktop\ITLPers\itlp1.jpg")