(VB) load a file matching string value of selected listbox item

  • Thread starter Thread starter DavidBasara
  • Start date Start date
D

DavidBasara

Guest
I'm trying to load a file using the string value of a combobox selected item. The text match and the variable description properly grabs the customer name from the list but my variables saved in a .hdf folder with customer name isn't working.
Private Sub lstName_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstName.SelectedIndexChanged
'Adds customer information to the labels on the form and changes
ChDir(c)
lstDevice.Items.Clear()
lstComment.Items.Clear()
Dim description As String = ""

description = lstName.SelectedItem.ToString()
Dim allFiles = Directory.EnumerateFiles(c + "\" + description + ".hdf")

For Each Str As String In allFiles

Dim values() As String = File.ReadAllText(Str).Split("|"c)
firstname = values(0)
lastname = values(1)
homephone = values(2)
cellphone = values(3)
address = values(4)
town = values(5)
state = values(6)
zipcode = values(7)
email = values(8)
Next
End Sub

Continue reading...
 
Back
Top