Read input from a file and once a user clicks an item from a combo box, the same sequential info wi
Read input from a file and once a user clicks an item from a combo box, the same sequential info will be displayed in a text box.
API Declarations
Private AddressArray(0 To 5) As String
Private PhoneArray(0 To 5) As String
Rate Read input from a file and once a user clicks an item from a combo box, the same sequential info wi
(1(1 Vote))
'Also you need to create a text file called ItemFile in notepad. Save this file in My Documents on your pc.
'this is what your input file should look like...copy it exactly the way I have it.
"320 North Street","340-9999"
"500 Creeks Landing Hwy","555-0000"
"122 Main St.","777-9999"
"400 Woodshire Ave","567-0000"
"12 South St.","545-9090"
"3455 Queens Ave.","456-0000"
below is the code you need. make sure you put the code in all the right places, if you have probs, email me. Ive executed my program 6 times and it works. Good luck!
here's the code you need:
Public Function Find_Address()
Dim x As Integer
'this function will read data from an input
'file and store data in an array for addresses and phone #'s.
'open input file
x = 0
Open "c:\My Documents\ItemFile.txt" For Input As #1
Do While Not EOF(1)
Input #1, AddressArray(x), PhoneArray(x)
x = x + 1
Loop
Close #1
End Function
Private Sub Combo1_Click()
Call Find_Address
Text1.Text = Combo1.Text & " , " & AddressArray(Combo1.ListIndex)
Text1.Text = Text1.Text & " , " & PhoneArray(Combo1.ListIndex)
End Sub
Private Sub Form_Load()
Combo1.Text = "Addresses"
'populate combo box
With Combo1
.AddItem "Ted Jones"
.AddItem "Michelle Loris"
.AddItem "Doug Simpson"
.AddItem "Laura Smith"
.AddItem "Greg Brown"
.AddItem "Mark White"
End With
End Sub
Read input from a file and once a user clicks an item from a combo box, the same sequential info wi Comments
No comments yet — be the first to post one!
Post a Comment