I want to pass a parameter to the VB executable file, and depending upon that parameter a particular form will open. Please guide
Printable View
I want to pass a parameter to the VB executable file, and depending upon that parameter a particular form will open. Please guide
You are looking for comman line arguments. In VB the command line arguments that are passed from the command line are stored in Command$ string. Here is a simple exampleI am assuming that the startup object will be SubMain and there are already two Forms present in project.VB Code:
Public Sub Main() If Command$ = "Form1" Then Form1.Show ElseIf Command$ = "Form2" Then Form2.Show End If End Sub
@Anik_sinha
Welcome on the forums :wave:
@Shuja Ali
what is the use of pasing parameter
Its like using switches in some application....for example with the pkzip utility you can the -t switch to test the zip files and something else...same like with excel.exe, notepad.exe, winword.exe if you type the file name with full path the application will be opened with the specified file name
if you type Excel.Exe C:\SomeDir\SomeFile.xls in the Run window excel will open excel with the specified file....
thanks
Here is a nice tutorial on Command Line Arguments.
good example by ipranks ;)