|
-
Dec 4th, 2007, 05:34 AM
#1
Thread Starter
New Member
Using a combobox to read data from a .txt file
I have a list of my members details in a .txt file. (name, address, tel no, etc)
I am able to view their names through a combobox.
How would i be able to view a specific members details in text boxes by selecting their name through the combobox?
Any help will be much appreciated, thankyou.
-
Dec 4th, 2007, 07:43 AM
#2
Re: Using a combobox to read data from a .txt file
Welcome to the forums. 
So, you select a name from the combo box. Then what should happen? What details do you want to view? How do you want to view them? From where are the details coming?
-
Dec 4th, 2007, 11:27 AM
#3
Thread Starter
New Member
Re: Using a combobox to read data from a .txt file
Ok so you select a name from the combo box and click a button so i can edit the member, then a new form opens with multiple text boxes. I have multiple members details stored in members.txt. When i click on a persons name their details should appear in this new form in the corresponding txt boxes. I want to be able to view all the information on the file(first name, last name, date of birth, address, contact number). The names in the combo box are generated from this .txt file.
Last edited by John108; Dec 5th, 2007 at 04:21 AM.
-
Dec 5th, 2007, 01:42 PM
#4
Re: Using a combobox to read data from a .txt file
Here is some code to get you started. I think a list box might work better than a combo box and you only need one form. Build a text box to hold the membership data and the an array of five text boxes to view the data elements:
Code:
Dim MyData() As String, ListSize As Integer
Dim LineDataArray() As String
Private Sub Form_Load()
ListSize = 2 ' One smaller than membership list
ReDim MyData(ListSize)
MyData(0) = "John, Jones, 1978, 13022 Franklin Street, 12345"
MyData(1) = "Mary, Smith, 1979, 10232 Washington Street, 14895"
MyData(2) = "Pete, Brown, 1986, 12321 Jefferson Street, 89523"
Text1.Text = ""
For I = 0 To ListSize
Text1.Text = Text1.Text & MyData(I) & vbCrLf
LineDataArray = Split(MyData(I), ",")
List1.AddItem LineDataArray(0) & LineDataArray(1)
Next
List1.ListIndex = List1.ListCount - 1 ' Select most recent member
End Sub
Private Sub List1_Click()
LineDataArray = Split(MyData(List1.ListIndex), ",")
For I = 0 To UBound(LineDataArray)
Text2(I).Text = Trim$(LineDataArray(I))
Next
End Sub
Each time you click on a different name in the list box, a different member's data is revealed in the text box array.
-
Dec 5th, 2007, 03:25 PM
#5
Re: Using a combobox to read data from a .txt file
Why do you bother with text files? Use database
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|