• Log in or sign up for an account here: https://www.sythe.org/login

using buttons to open a new form?

Status
Not open for further replies.

mike_ftl

Member
Joined
Oct 19, 2008
Sythe Gold
5
Messages
85
Location
San Jose
i made a form that has 3 buttons.
I need to know how to use buttons to open a new form and open another application.
Also how can i make the program minimize to tray?
if you have the answer or know a good resource to a vb noob
Thanks

( i am making a shutdown timer for myself as the ones i have on my computer are absolute shit and dont work.)
 
To make a button open a form do the following:

Code:
Private Sub [COLOR="DarkGreen"]Command1[/COLOR]_Click()
[COLOR="Red"]Form2[/COLOR].Show
End Sub

Change the green text to the name of your button.
Change the red text to the name of the form you wish to open.

If you got any questions feel free to ask.
 
Almost the same way, except:

Code:
Private Sub [COLOR="DarkGreen"]Command1[/COLOR]_Click()

Dim RetVal
RetVal = Shell("[COLOR="Red"]file location[/COLOR]") 


End Sub
Once again,
Change the green text to the name of your button.
Change the red text to the location of the file you wish to open.

For example:

Code:
Private Sub Command1_Click()

Dim RetVal
RetVal = Shell("C:\WINDOWS\System32\calc.exe") 

End Sub

That above code will open the Calculator.
 
<3 n4n0
Discord Verified
Two Factor Authentication User
Community Participant
Spam Forum Participant
Sythe's 10th Anniversary
Sythe Awards 2011 Winner
Please post in the forum specific for the language you are working with next time... What language is this anyways? VB .Net?
 
Please post in the forum specific for the language you are working with next time... What language is this anyways? VB .Net?

You should move it Mr. Mod. It's VB6, by the way.
 
I was going to, but I did not know to where... :P
haha, and you're supposed to be programmer mod xD
hehe, anyways.. I believe you should move this thread and this (his other shutdown timer help thread) http://sythe.org/showthread.php?t=574315
to visual basic .net forum, since he said he uses visual studio 2008 (= vb.net)... and that's probably why the code given doesn't work for him :)
 
i made a form that has 3 buttons.
I need to know how to use buttons to open a new form and open another application.
Also how can i make the program minimize to tray?
if you have the answer or know a good resource to a vb noob
Thanks

( i am making a shutdown timer for myself as the ones i have on my computer are absolute shit and dont work.)

1) To open a new form, add the form to your project and then add this code in the Click procedure for the button:
Code:
frmName.show [vbModal]
The vbModal is optional; if no vbModal is present in the code, you can switch between forms without closing the second form; if vbModal is present, you must close the second form before you can view the first.

2) To open a program, you must use the Shell command. I'm not very experienced at it, so you will have to use the MSDN library or Google it.

3) Unfortunately, I don't know the answer to this, and I'm not sure it's possible, so sorry I can't help with that.

I hope the one answer I gave you will be helpful :p lol Good luck!
 
Status
Not open for further replies.
Runescape Gamblingrunescape gambling
Back
Top