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

Recommended Answers

All 10 Replies

you can use Shell Function

Syntax : Shell(PathName, [WindowStyle])

example :

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

Thx

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.

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

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.

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

Will do, thanks.

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:

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?

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

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.