Click to See Complete Forum and Search --> : Simple VB Question


ai3rules
04-21-2004, 01:39 PM
I am literally just starting to learn VB, and I am reading a book which gave me an sample word processor to put together. It seems to work fine, except for one click event.

Private Sub cmdOpen_click()
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then Textbox.Text = CommonDialog1.Filename
End Sub

When I run that, it loads the "Windows open dialog" box. However, when I select a .txt file to open - instead of displaying the contents of the text file (like I am assuming it is supposed to) it displays the path of the file in the text box.

Can anyone tell me what I am doing wrong?

I hope I am asking this in the correct forum - people here seem to know everything, so I thought it was my best bet.

Anyway, I appreciate any help.
Thank You.

buntine
04-21-2004, 01:45 PM
Your not doing anything wrong, nor is the application you wrote.

The preceding code will prompt the user with the standard Windows 'File Open' dialog, wait for a selection, and then display the path of the file which was chosen.

To actually display the contents of the text file would take more code. You will probably get to that later in the book you are reading.

Also, please post any VB related questions in the .NET forum. ;)

Regards,
Andrew Buntine.

ai3rules
04-21-2004, 03:06 PM
Hi, I was hoping that was the case - Thank you for you reply.

I will post further VB questions in the .net forum, thanks for the heads up.