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.
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.
Bookmarks