Results 1 to 8 of 8

Thread: [2008] Basic, easy question

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    6

    [2008] Basic, easy question

    lol okay i agree im a complete noob at this.
    This is what i need to do when i click the Enter button i want it to open up game.exe, game exe and the game launcher will be in the same folder
    Thanks
    Last edited by AllanS; Dec 6th, 2008 at 02:13 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Basic, easy question

    Instead of using the thread title to tell us that it's a basic, easy question, please let us judge the level of difficulty and use the thread title to actually describe the problem.

    As for the question, we need more info. What does your launcher UI look like? Why are you using a launcher instead of just a regular Windows shortcut?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    6

    Re: [2008] Basic, easy question

    mmm okay, well my game launchers very simple, it haves 3 buttons and a background, buttons are Enter, Forums, Exit, there is also a webbrowser on it for news.
    Im and using a luancher because it produces more infomation about the game.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Basic, easy question

    Can I assume that your Enter button is to run the game and your Exit button is to quit the app? If so then you should assign them to the AcceptButton and CancelButton properties of the form respectively. The AcceptButton is "clicked" when the user hits the Enter key and the CancelButton is "clicked" when the user hits the Escape key.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    6

    Re: [2008] Basic, easy question

    Quote Originally Posted by jmcilhinney
    Can I assume that your Enter button is to run the game and your Exit button is to quit the app? If so then you should assign them to the AcceptButton and CancelButton properties of the form respectively. The AcceptButton is "clicked" when the user hits the Enter key and the CancelButton is "clicked" when the user hits the Escape key.
    lol im a complete noob sorry i have no idea, think we could chat on msn or somthing?

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Basic, easy question

    Quote Originally Posted by AllanS
    lol im a complete noob sorry i have no idea, think we could chat on msn or somthing?
    You've set properties on your form before, e.g. Text. This is no different. Open the form in the designer, open the Properties window and set the AcceptButton and CancelButton properties. Done.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    PowerPoster keystone_paul's Avatar
    Join Date
    Nov 2008
    Location
    UK
    Posts
    3,327

    Re: [2008] Basic, easy question

    If I understand correctly this question is about how to launch a program not how to set a default button on a form.

    All you need to do is add a line at the top of your code to import "System.Diagnostics" and then use the Process.Start method :

    vb Code:
    1. Imports System.Diagnostics
    2.  
    3. Public Class frmLauncher
    4.  
    5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.  
    7.         Process.Start("game.exe")
    8.  
    9.     End Sub
    10.  
    11. End Class

    You would probably want to throw in some error checking to make sure that game.exe is there etc, but that code will launch the application assuming it is there in the same folder as the launcher as you stated.

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] Basic, easy question

    Quote Originally Posted by keystone_paul
    If I understand correctly this question is about how to launch a program not how to set a default button on a form.

    All you need to do is add a line at the top of your code to import "System.Diagnostics" and then use the Process.Start method :

    vb Code:
    1. Imports System.Diagnostics
    2.  
    3. Public Class frmLauncher
    4.  
    5.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    6.  
    7.         Process.Start("game.exe")
    8.  
    9.     End Sub
    10.  
    11. End Class

    You would probably want to throw in some error checking to make sure that game.exe is there etc, but that code will launch the application assuming it is there in the same folder as the launcher as you stated.
    Good point. I kinda focused on the:
    when i click the Enter button
    and not so much on the:
    i want it to open up game.exe
    So, keystone_paul has shown you how to execute a file on a Button Click and I've told you how to invoke that Button Click when the user hits the Enter key. That just about covers the entire question.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width