Click to See Complete Forum and Search --> : getting text data


philonous
January 30th, 2005, 08:30 AM
i've made a program which works fine, but i want to add some information to it like help files and was wondering how to do it, ever it could be html help files (like a mini website within my program) or just plain text document i could call when a button is pressed...or maybe i was thinking of getting the text and other data from a pdf file or a word document or a normal txt document to display in textboxes.

my problem is calling things like webpages and documents, i've tried out code from my textbox but that doesn't work (something to do with io.streamreader?) anyway we didn't learn how to do this at uni and the module finished last semester and so now i'm teaching my self via doing little projects which is why i'm asking here.

to summarise:

1) how do i get a notepad (example) document to open via a button press?
2) how would i display this data inside of a textbox?
3) how would i call a webpage (internal or external) via a button press?

also

4) i've been trying out putting menus on my program which works fine in vs but when i run the application the menus don't appear...what was i doing wrong?

thanks for taking the time to read this, when i learn more stuff i'll be one of the people on here answering all of the questions:)

MikeKraken
January 31st, 2005, 06:58 PM
I can help you with question 1 and 3, anyway...

Try
System.Diagnostics.Process.Start("notepad.exe", fileName)
Catch w32e As System.ComponentModel.Win32Exception
'error handling here
End Try

fileName is a String with the location of your text file. If the user hasn't screwed around with their environment options, Notepad should open just by using that code and putting it in your Button.Clicked event code.

For question 3, you would probably want to use this code:

System.Diagnostics.Process.Start("http://www.yourURLhere.com")

This will launch the URL in the user's default Internet browser (in case they have some sense and don't use IE ;)).

I'm not too sure without seeing what you're doing, but for your fourth mention, I think you might have to set the menu field for your form.

Hope that helps!

... Mike. ^_^

philonous
February 1st, 2005, 06:30 PM
the code for calling notepad worked perfectly, thanks.

what if i wanted to call an embedded file? what would the path be?

on my computer doing things the original way is great, it's just if some else uses my program on their computer the path will be different, and so won't work, i don't know how to get products installed:(

SatyaV
February 1st, 2005, 06:43 PM
Since you are just doing test projects ... how about this code for invoking notepad :)

Dim myProcess As New Process
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.FileName = "notepad.exe"
myProcess.Start()

philonous
February 1st, 2005, 07:30 PM
Since you are just doing test projects ... how about this code for invoking notepad :)

Dim myProcess As New Process
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.FileName = "notepad.exe"
myProcess.Start()


this indeed works but calls up a new notepad document.

question now is: how would i transfer the text from a texbox within my program into a note pad document which the user could then save.

SatyaV
February 2nd, 2005, 10:43 AM
First write the contents of your textbox to disk. Use that filename as an argument to the notepad code. Assuming that the file that you saved to disk was C:\abc.txt, to invoke that in notepad, use

Dim myProcess As New Process
myProcess.StartInfo.UseShellExecute = False
myProcess.StartInfo.FileName = "notepad.exe"
myProcess.StartInfo.Arguments = "C:\abc.txt"
myProcess.Start()

SatyaV
February 2nd, 2005, 10:47 AM
Ok, the previous response is screwup 101.

It appears you want the data to be transferred to notepad directly and allow the user to save it ... meaning the user has an option not to save it too. This would be difficult to do - you are talking DDE kind of stuff now.

Easiest is to give a save button next to your textbox, which the uses clicks to save what he sees in the textbox - why go through the hassle of notepad.
Else create a temp file, load up in notepad using the previous code, and cleanup after the user closes notepad.

HTH

philonous
February 2nd, 2005, 02:10 PM
I've tried to save it directly from the textbox but it doesn't seem to be working.

i can call up the save dialog box and i've set it to save the document as a .txt file, however when i write the name in and click save it says the the file doesn't exist and won't let me save it, what am i doing wrong?