1.11M Members

execute programs from vb

 
0
 

hi,
How can u execute an external program in vb?

 
0
 

you can use Shell Function

Syntax : Shell(PathName, [WindowStyle])

example :

Private Sub Form_Load()
    Shell ("notepad")
End Sub
 
0
 

Thx

 
0
 

Hey, I would like some help also, if possible.

I'm trying to execute a game through VB (Click the command button and the game opens type thing, possibly then connecting to a server.)

If anyone has any help or links to somewhere where I can look for help, it would be greatly appreciated.

Thanks, Stibbeh.

 
0
 

Is the game you are talking about an online game??? For that matter, you can utilize the iNet tool

 
0
 

Is the game you are talking about an online game??? For that matter, you can utilize the iNet tool

Thanks for your reply.
Yes it is an online game, Jedi Knight 2, what's this iNet tool? Ole?

Thanks again.

 
0
 

Yes,
you can use an array of tools, the MS Internet controls and Internet Transfer control. you can create your own web broweser or simple open URLs. Try it out

 
0
 

Will do, thanks.

 
0
 

declare this in your bas:
Public Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

and to execute a programas use this:
Call ShellExecute(0&, vbNullString, "program.exe", vbNullString, "path of the program", vbNormalFocus)

bye, :cheesy:

 
0
 

declare this in your bas:
Public Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

and to execute a programas use this:
Call ShellExecute(0&, vbNullString, "program.exe", vbNullString, "path of the program", vbNormalFocus)

bye, :cheesy:

I tried this, this is what i have written:

Private Sub cmdOne_Click()
MsgBox ("Are you sure you want to play this game?")
End Function
Public Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Call ShellExecute(0&, vbNullString, "cstrike.exe", vbNullString, "C:\Documents and Settings\Games\My Documents\Games\Counter - Strike 1.6\Counter-Strike 1.6", vbNormalFocus)
End Sub

And it still doesn't work, i am a newbie to all this and im trying to create a menu that comes up on startup where i can just click on a command button and the game begins. What is wrong with all that code there?

 
0
 

put this code right below the OPTION EXPLICIT of your form or in your module(not in class module)

Public Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

End Sub 'this end sub should not be included, delete it

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article