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.
20 posts Page 2 of 2
Contributors
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: vb.net textfile help.
Mark
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
http://www.mbappz.com
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: vb.net textfile help.
visualtech
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)
Last edited by visualtech on Tue Jul 23, 2013 10:35 pm, edited 1 time in total.
Image
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: vb.net textfile help.
Mark
I want it to display the rest of the records information in text boxes when i click on the one in the list box.?
http://www.mbappz.com
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: vb.net textfile help.
Mark
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?.
http://www.mbappz.com
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: vb.net textfile help.
visualtech
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:
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

Image
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: vb.net textfile help.
Mark
I was just wanting to use the one text file?
http://www.mbappz.com
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: vb.net textfile help.
visualtech
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)
Image
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: vb.net textfile help.
Mark
Its just a college app that ive been working on.

But wanting to beable to do it all in one text file.
http://www.mbappz.com
User avatar
visualtech
VIP - Donator
VIP - Donator
Posts: 265
Joined: Sat Nov 19, 2011 2:19 pm

Re: vb.net textfile help.
visualtech
in that case, use the Split Info Method :)
Image
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: vb.net textfile help.
Mark
How do io this
http://www.mbappz.com
20 posts Page 2 of 2
Return to “Tutorial Requests”