vb.net textfile help.
Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
This is the code i use to search but it shows everything in the list box.
Private Sub cmdSearch_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSearch.Click
Dim i As Short
Dim searchname As String
lstDetails.Items.Clear()
searchname = InputBox("Enter name to search for", "Find Customer")
searchname = UCase(searchname)
For i = 1 To numrecs
With CustArray(i)
If searchname = .CustName Then
lstDetails.Items.Add(.CustName)
lstDetails.Items.Add(.Address)
lstDetails.Items.Add(.Town)
lstDetails.Items.Add(.Phone)
Exit Sub
Else : MsgBox("No record for this customer")
End If
End With
Next
End Sub
Private Sub cmdSearch_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSearch.Click
Dim i As Short
Dim searchname As String
lstDetails.Items.Clear()
searchname = InputBox("Enter name to search for", "Find Customer")
searchname = UCase(searchname)
For i = 1 To numrecs
With CustArray(i)
If searchname = .CustName Then
lstDetails.Items.Add(.CustName)
lstDetails.Items.Add(.Address)
lstDetails.Items.Add(.Town)
lstDetails.Items.Add(.Phone)
Exit Sub
Else : MsgBox("No record for this customer")
End If
End With
Next
End Sub
ohh kk. So what you can do is append the values to a string and then add the single string to the listbox
Example:
Dim sVal as string = .CustomerName & " | " & .SecondValue & " | " ..... so on....
lstBox.items.add(sVal)
Example:
Dim sVal as string = .CustomerName & " | " & .SecondValue & " | " ..... so on....
lstBox.items.add(sVal)
Last edited by visualtech on Tue Jul 23, 2013 10:35 pm, edited 1 time in total.
I want it to display the rest of the records information in text boxes when i click on the one in the list box.?
i need them to go in to text boxes not the list box.
for example if i click on a name in my list box it then shows there address and does the same for the rest of the names?.
for example if i click on a name in my list box it then shows there address and does the same for the rest of the names?.
So, if i got this right; there is a listbox with the names of the customer and some text boxes. So, if a user selects the name from the listbox. the text boxes get populated with all the information, right?
If so, you can store the information as separate text files and then read and parse the information when the user changes the index. For eg.
You have a file John Doe.txt with the following content: Acme, Inc|SomeInfo|Etc.|Etc
Add this code to the ListBox's selectedindexchanged event:
If so, you can store the information as separate text files and then read and parse the information when the user changes the index. For eg.
You have a file John Doe.txt with the following content: Acme, Inc|SomeInfo|Etc.|Etc
Add this code to the ListBox's selectedindexchanged event:
Code: Select all
If Not System.Io.File.Exists(application.startuppath & "/data/" & listbox1.selecteditem.tostring()) Then
MsgBox("Suitable datafile not found.")
Exit Sub
End If
Dim str as string = my.computer.filesystem.readalltext(application.startuppath & "/data/" & listbox1.selecteditem.tostring())
Dim company as string = str.split(new char() {"|"})(0)
Dim someinfo as string = str.split(new char() {"|"})(1)
' And so on and so forth.
TextBox1.text = company
TextBox2.text = someinfo
Well, there are a few pros and cons for both, Single Text File and Split Info Files:
Single Text File:
Pros
- Looks arranged and professional.
- Easier for the user to manage.
Cons
- Hard to append and delete values.
Split Info Files (the way i told you):
Pros
- Very easy to access, append, delete.
- You can hold quite a bit for info in it.
- If stored in a folder, looks organized.
Cons
- Clutters Up (too many files : One for each user)
So, if you want a simple, functional application, use the Split info file option; however, if it's a business app: try to use the XML file (single text file)
Single Text File:
Pros
- Looks arranged and professional.
- Easier for the user to manage.
Cons
- Hard to append and delete values.
Split Info Files (the way i told you):
Pros
- Very easy to access, append, delete.
- You can hold quite a bit for info in it.
- If stored in a folder, looks organized.
Cons
- Clutters Up (too many files : One for each user)
So, if you want a simple, functional application, use the Split info file option; however, if it's a business app: try to use the XML file (single text file)
Its just a college app that ive been working on.
But wanting to beable to do it all in one text file.
But wanting to beable to do it all in one text file.
Copyright Information
Copyright © Codenstuff.com 2020 - 2023