0

I have a visual basic form that is storing data into a text file. I placed a button on the form to allow the user to see the info in the text file whenever its clicked (so the user does not have to browse to the location of the file to see the data). Can anyone helps me implement this.

PS: I see a similar question that was asked 11 years ago but I did not really understand the solution and also new visual studio not accepting any of the solution (may be depleted) here is the link to the old question : How to display the text file while clicking the button Thanks

Ktrel
  • 115
  • 1
  • 9
  • What is the *actual* language you're using? You link to a VB6 question but tagged with a bunch of other things. – Tim Williams Oct 19 '20 at 00:34
  • The example you quote shouldn't be difficult unless you wish to follow the selected answer. The next 3 answers build just one solution and allow you to copy/paste the 3 lines of your choice (the differences all nicely explained). I think that's where you should start. If you have a problem, post the code you will then have here and explain the difficulty you face. – Variatus Oct 19 '20 at 00:41
  • Sorry. i am using visual basic (2017). – Ktrel Oct 19 '20 at 02:48
  • The attach link (http://www.vb-helper.com/howto_shellexecute.html) is using ShellExecute API and from searches on google does no longer work in visual basic – Ktrel Oct 19 '20 at 02:50
  • `Dim theText As String = IO.File.ReadAllText(yourFilePath)`. – 41686d6564 stands w. Palestine Oct 19 '20 at 02:54
  • Does this answer your question? [vb.net Reading from a .txt file and displaying the contents](https://stackoverflow.com/questions/25529873/vb-net-reading-from-a-txt-file-and-displaying-the-contents) – 41686d6564 stands w. Palestine Oct 19 '20 at 02:56
  • Note that VB.NET (the one that you're using) and VB6 (the one in the question you linked) are two different languages, so don't get them confused. VBA, VBScript, and Basic are three _other_ languages (although VBA is arguably a subset of VB6). – 41686d6564 stands w. Palestine Oct 19 '20 at 03:00
  • Ok. My apologies. I thought VBA, VBScript, and VB.net were all the same but just different versions of the same language kind like python 2 and python 3. I apologize then. I guess I need my help in VB.net then. – Ktrel Oct 19 '20 at 14:36
  • So, just to be 100% clear on what you want to happen. When you click your button, you simply want to open the text file in the default program? – Hursey Oct 19 '20 at 22:19

1 Answers1

0

Try using the My component to read the text.

Dim text as string = My.Computer.Filesystem.ReadAllText(*your path*)

If you want to open the file in the default program then try:

process.start(*your path*)