visual basic 6.0 gui

I am using visual basic 6.0 on windows xp and I want to create a gui which has a command button and a text window. I want the command button, when pressed, to read txt from a specific text file I have on my computer and then display this text in the window of the gui. Can you help ?
raymosheaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jcullinsCommented:
this is what i would do.

Create your form, drop in your textbox control, drop in your command button control.  then double click on the command button and drop in this procedure.  Also, please note that this code below is based off of the default naming used in vb6

Private Sub Command1_Click()
Dim strLine As String

Text1.Text = ""
Open "<path_to_your_file.txt" For Input As #1
Do
 Line Input #1, strLine
 Text1.Text = Text1.Text & strLine & vbCrLf
Loop Until EOF(1)
Close #1
End Sub


Once you click the command button, it will automatically open your file, read each line and put it into your textbox control.

Let me know if there is anything else you need.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jcullinsCommented:
and just to clarify, lets say you wanted to open and read C:\temp\document.txt you would put in your open statement

open "C:\temp\document.txt" for input as #1

i just wanted to clarify that.
0
3_SCommented:
To have a more robust program modify the code of jcullins

Private Sub Command1_Click()
Dim strLine As String

Text1.Text = ""
nFilenum = FreeFile
Open "<path_to_your_file.txt" For Input As #nFilenum
Do
 Line Input #nFilenum , strLine
 Text1.Text = Text1.Text & strLine & vbCrLf
Loop Until EOF(1)
Close #nFilenum
End Sub
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

raymosheaAuthor Commented:
cheers jcullins it worked like a charm! I'm only a beginner at vb6.0 so i'll be posting a good few questions in this foeum if you want the expert points!
0
raymosheaAuthor Commented:
Thanks 3 s i'll have a look at this
0
jcullinsCommented:
No problem, glad the solution worked perfect for you.  Definitely, post your questions and i will be happy to answer them.

I'm always glad to help!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.