Adblock breaks this site

using buttons to open a new form?

Discussion in 'Programming General' started by mike_ftl, Feb 21, 2009.

Thread Status:
Not open for further replies.
  1. mike_ftl

    mike_ftl Member

    Joined:
    Oct 19, 2008
    Posts:
    85
    Referrals:
    1
    Sythe Gold:
    5
    using buttons to open a new form?

    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.)
     
  2. World Domination

    World Domination Guru
    Banned

    Joined:
    Apr 9, 2007
    Posts:
    1,563
    Referrals:
    3
    Sythe Gold:
    5
    using buttons to open a new form?

    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.
     
  3. mike_ftl

    mike_ftl Member

    Joined:
    Oct 19, 2008
    Posts:
    85
    Referrals:
    1
    Sythe Gold:
    5
    using buttons to open a new form?

    wow thank you so much.
    You dont know how much you just helped me.
    what about opening an exe file?
     
  4. mike_ftl

    mike_ftl Member

    Joined:
    Oct 19, 2008
    Posts:
    85
    Referrals:
    1
    Sythe Gold:
    5
    using buttons to open a new form?

    one thing it says form 5 is not declared.
    whats that mean
     
  5. World Domination

    World Domination Guru
    Banned

    Joined:
    Apr 9, 2007
    Posts:
    1,563
    Referrals:
    3
    Sythe Gold:
    5
    using buttons to open a new form?

    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.
     
  6. SuF

    SuF Legend
    Pirate Retired Global Moderator

    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary
    using buttons to open a new form?

    Please post in the forum specific for the language you are working with next time... What language is this anyways? VB .Net?
     
  7. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    using buttons to open a new form?

    You should move it Mr. Mod. It's VB6, by the way.
     
  8. SuF

    SuF Legend
    Pirate Retired Global Moderator

    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary
    using buttons to open a new form?

    I was going to, but I did not know to where... :p
     
  9. hampe-92

    hampe-92 Forum Addict

    Joined:
    Jul 10, 2008
    Posts:
    328
    Referrals:
    0
    Sythe Gold:
    0
    using buttons to open a new form?

    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 :)
     
  10. abluescarab

    abluescarab Newcomer

    Joined:
    Oct 10, 2008
    Posts:
    18
    Referrals:
    0
    Sythe Gold:
    0
    using buttons to open a new form?

    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!
     
  11. Darthatron

    Darthatron Massive Troll
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    May 22, 2006
    Posts:
    1,612
    Referrals:
    3
    Sythe Gold:
    0
    using buttons to open a new form?

    Stop grave digging already. >_>
     
< Paying you to program $$$ | Need Auto Clicker >
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site