thanks for any help
just want (in Windows ) the person who opens a text file -that it will open with my note pad type program not windows notepad,
no answer so i will ask once more!
can some one please tell me how to click a text file and get it to open with my vb notepad program i use file open with my program bt when my program opens the rich text box is empty
Dim MyFileStream As New FileStream(FilePath, FileMode.Open)
RichTextBox1.LoadFile(MyFileStream, _
RichTextBoxStreamType.PlainText)
MyFileStream.Close()
-----------------------------
file path is the text file they ck so how to i know it

about rich text box so i will ask once more! please help!!!!
GilesCollingwood
In your form load event try adding code like this:
If My.Application.CommandLineArgs.Count <> 0 Then Dim argument As Stringargument =
My.Application.CommandLineArgs(0) TryRichTextBox1.LoadFile(argument, RichTextBoxStreamType.RichText)
Catch ex As Exception TryRichTextBox1.LoadFile(argument, RichTextBoxStreamType.PlainText)
CatchMsgBox(argument &
" ignored") End Try End Try End IfTonyGreen
Please try and put a more descriptive title next time
I think from your description your having a problem allowing them to pick the file which you will use to load the VB Editor application you have written.
If this is the question then the control that you need from within you application is OpenFileDialog Control
As I dont know what controls you are using for your editor but this will show how to use this control to populate a rich text control. If your using some other control you may have to rework this code a little.
http://abstractvb.com/code.asp A=969
If its something more then please let us know a more fuller description of what youa are trying to achieve.
David Russell
Mario,
I believe Spotty and I both expressed a desire for a more concise problem statement from kathy. In short I'm suggesting that her original question proposed things that were less than optimal.
AT any rate, I'm hoping that she has what she needs now to continue.
Grant Haugen
Hi Kathey,
regarding your concern, try this code on the click event of the text box, i think it will answer your question:
Private Sub RichTextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.Click If RichTextBox1.Text <> "" Then TryDim MyFileStream As New FileStream(RichTextBox1.Text, FileMode.Open)
RichTextBox1.LoadFile(MyFileStream, _
RichTextBoxStreamType.PlainText)
MyFileStream.Close()
CatchMsgBox(Err.Description)
End Try ElseMsgBox(
"Please provide the Path in the text box, like c:\test1.txt") End Ifdo not forget to include the following: Imports System.IO
good luck
mario
Marc Allard
I thought the rich text box had a Text property you could set, so
RichTextBox1.Text = System.IO.File.ReadAllText(FilePath)
or something along those lines
rabidrobot
thank you,thank you,thank you!!!!!!!!!!!!!!!!!!
works Great! thats what i needed.
Tall Dude and James you are wonderful!
Best wishes
Kathy
DannyK2316
Mario,
I don't think this is a good solution at all. I believe spotty's solution is the standard and appropriate one, requiring far less of the user than yours does.
I also agree with Spotty in his desire for a clearer problem statement. Unforntunately Kathy, I found it difficult to understand what you were asking for.
The openfile dialog, followed by a process.start for notepad.exe with the filename name supplied to the command switch property would seem to be the way to proceed to me.
Daniel Read
yes ReneeC,
i appreciate your decision for you being a high collaborator in microsoft forums.
You are right, spotty's solution suggesting the use of OpenFiledialog is the best solution.
but in my reply to kathy i was just answering her question about file path which she hilighted in yellow:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim MyFileStream As New FileStream(FilePath, FileMode.Open)
RichTextBox1.LoadFile(MyFileStream, _
RichTextBoxStreamType.PlainText)
MyFileStream.Close()
-----------------------------
file path is the text file they ck so how to i know it
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
any way, if the problem is solved, then this is a benefit for the group i.e for each one of us...
Regards
mario
GuoJingwei
When you say" Click a text file and get it to open with my vb notepad program" exactly what do you mean Do you mean you want to be able to Click on a File DIRECTLY from within your vb notepad program and it automatically open, in your program OR do you mean you would like your user to be in Windows Explorer ( just an example) and when they come to a Text file and Click on it, instead of opening that file in Windows Notepad( if that person has not changed the default action of clicking a text file in Explorer and it opening Notepad), it opens up in your vb Notepad program Both things can be done, but, you need to be a bit more clear on what you are actually wanting to do.
james
aka:Trucker
Igore65
Kathy, I know you thought this was clear.....
I would offer and alternative and preferable one that does not have the word click in it a single time.
"
I start my computer, on the desktop, I invoke Windows Explorer and selecte the Documents folder. in that folder are many files, many of which are text files (.txt). Double Clicking in explorer causes causes notepad to open and display that file.
I want you to click one (WHAT ) and it (What does it refer to) opens my notepad program I made with vb2005. (This sentence isn't clear Are you saying you made a program that opens notepad and a document )
Using the CONTEXT MENU and selecting OPEN, when I select on a txt file it opens my program but the rich textbox is empty.
---------------------------------------------------------
OK. There's a clear problem statement. Notice that things are clearest when you don't resort to pronouns.
Next step....
We need to see the code. Did you read the suggestions at the top of the forums
"Dirk Reimers
Tall Dude, just wanted to let you know your solution works good for me. I have tried several different things, to do this same thing and always seemed to have problems. This one is a keeper.
james
aka:Trucker
MarkHeindl
Let me try to be more clear, you start your computer, your on your desktop, you click the documents folder in that folder are a lot of files, many are text files (.txt) you click one and it opens in notepad.
I want you to click one and it opens in my notepad program I made with vb2005.
So I went to the properties and selected open with … (looked for my program) and when I click on a txt file it opens my program but the rich textbox is empty.
scottsignalscape
OK, your correct in changing the association of the program so that for txt files they are pointing to you application but you also need to take in a command line parameter which will be used to load the contents into you textbox
The following shows a simple Module that contains a module with a sub main that has a parameter of cmdargs() as string. This will enable you to call your application with a filename after it and it should load the contents into the textbox control.
So If my application was called Foo and it was compiled I could go to command windows and type Foo.exe C:\test.txt and it would load the contents of test.txt into my textbox in foo.
This is in essence what explorer is doing - it is calling the application associated with the extension and calling it providing the filename as a first command line parameter.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Module Module1
Sub main(ByVal cmdargs() As String)
Dim frm As New Form1
Dim strFilename As String
If UBound(cmdargs) >= 0 Then
strFilename = cmdargs(0)
frm.RichTextBox1.LoadFile(strFilename, RichTextBoxStreamType.PlainText)
Else
frm.RichTextBox1.Text = "No file specified"
End If
frm.ShowDialog()
End Sub
End Module