Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening a .txt file and sending data to a text box

Status
Not open for further replies.

gophertee

Programmer
Oct 11, 2000
27
US
Hello, I have two questions (pretty basic for you guru's).
#1: Using a cmdbutton on a form, how do I open a file that is located on my A:\Sample.txt.

#2: I have data in this Sample.txt which looks something like this;
Line#1
WidgetA, 1234, WidgetB

Line#2
WidgetC, 5678, WidgetD

In my form I have text boxes whereas:
Text1 will read in WidgetA
Text2 will read 1234
Text3 reads WidgetB
Text4 will read in WidgetC
Text5 will read 5678
Text6 reads WidgetD

Any help would be appreciated. If you guide me through this task and ever in the Minneapolis area I will treat ya to lunch or dinner.
Thanks~~
 
aaahhh there is an offer that I can't refuse (even though I don't hang around Minneapolis much...)

---------------------------------------------------------
Dim InFile as byte, InLine as String
Dim ArrTmp as variant

On Error goto ErrHndl:
InFile = freefile
open "A:\sample.txt" for input as #InFile
line input #InFile, inline
Arrtmp = split(inline,",")
text1.text =arrTmp(0)
text2.text =arrTmp(1)
text3.text =arrTmp(2)
line input #InFile, inline
Arrtmp = split(inline,",")
text4.text =arrTmp(0)
text5.text =arrTmp(1)
text6.text =arrTmp(2)
close #infile

exit sub
ErrHndl:
Msgbox err.description

---------------------------------------------------------
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top