1,105,644 Community Members

execute programs from vb

Member Avatar
Suriv
Newbie Poster
2 posts since Oct 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
invisal
Posting Pro
568 posts since Mar 2005
Reputation Points: 292 [?]
Q&As Helped to Solve: 64 [?]
Skill Endorsements: 0 [?]
 
0
 

you can use Shell Function

Syntax : Shell(PathName, [WindowStyle])

example :

Private Sub Form_Load()
    Shell ("notepad")
End Sub
Member Avatar
Suriv
Newbie Poster
2 posts since Oct 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thx

Member Avatar
Stibbeh
Newbie Poster
6 posts since Oct 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
extofer
Posting Whiz in Training
239 posts since Aug 2005
Reputation Points: -2 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
Stibbeh
Newbie Poster
6 posts since Oct 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
extofer
Posting Whiz in Training
239 posts since Aug 2005
Reputation Points: -2 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
Stibbeh
Newbie Poster
6 posts since Oct 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Will do, thanks.

Member Avatar
mstangeh
Newbie Poster
3 posts since Oct 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
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:

Member Avatar
blobby_427
Newbie Poster
1 post since Apr 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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?

Member Avatar
wen_dell8
Newbie Poster
1 post since Apr 2007
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article