VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Read input from a file and once a user clicks an item from a combo box, the same sequential info wi

by Brandon (46 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 21st July 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



'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








Download this snippet    Add to My Saved Code

Read input from a file and once a user clicks an item from a combo box, the same sequential info wi Comments

No comments have been posted about Read input from a file and once a user clicks an item from a combo box, the same sequential info wi. Why not be the first to post a comment about Read input from a file and once a user clicks an item from a combo box, the same sequential info wi.

Post your comment

Subject:
Message:
0/1000 characters