Hey ya'll

For one of my assignments I gotta produce some small VB programs.
One of them has to be a menu. A menu that does whatever I want it to. I can't find any tutorials that help :|

I have Visual Basic.Net 2003.
I know how to ADD the menu items. BUT i dunno how to code them to do what I want.
This is how I want my menu to be:

File >> Open. Save. Exit
Edit >> Copy. Paste. Remove.

and maybe another menu item....

SO I'd like some menu tutorials where I can get ideas from or help direct from you guys.

Any help would be appreciated. Thanks.! :)

Recommended Answers

All 11 Replies

Double Click The Menu Item, And Add The Code To The Menu Item

Double Click The Menu Item, And Add The Code To The Menu Item

Hey ya'll
I know how to ADD the menu items. BUT i dunno how to code them to do what I want.

:S

oh, duh... read that all wrong. Add an OpenFileDialog, and a SaveFileDialog to the form. Double click the menu item for Open, and put:

OpenFileDialog1.ShowDialog()
MsgBox(OpenFileDialog1.FileName)

Double Click on the Quit or Exit menu And Put:

end

Double Click on the Save Menu and put:

SaveFileDialog1.ShowDialog()
MsgBox(SaveFileDialog1.FileName)

That's a pretty good start.

thanks :)
will try that tomorrow

thanks again
it worked :)
I've figured out how to do the copy paste remove thing :)

Very good. I'm glad it's solved.

Another question.

How do I have it so that only the highlighted text is copied from one text box to another. Instead of all the text in one box to another ?

Clipboard.SetText(TextBox1.SelectedText) :)

if that answers your question, you can mark the thread as solved.

yup. that's the answer.
cheers mate :)

one LAST question. using the openfiledialog tool, how do I open a txt file so that it displays in the text box or list box?

that is my final question

cheers 4 any help

Didn't check if VB.NET 2003 supports all these features, but here's the code

OpenFileDialog1.CheckFileExists = True
OpenFileDialog1.CheckPathExists = True
OpenFileDialog1.DefaultExt = "txt"
OpenFileDialog1.FileName = ""
OpenFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
OpenFileDialog1.Multiselect = False
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
   TextBox1.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog1.FileName)
End If

And I suggest starting a new thread for each different question. That helps both those who answer the questions and those who search for a solution to their problem :)

commented: Very Well Done. +9

thanks alot! ^
appreciated :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.