Passing Value to form exe

kobezt08

Member
Joined
Dec 30, 2004
Messages
6
Programming Experience
Beginner
I need to pass a string value into an window form app where the string will be used to validate wheather the form should or should not be shown/loaded base on a hardcode ID. Any kind soul can teach me?
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
loop through the evironment's command line arguements:

VB.NET:
 Dim strStartupArguments() As String = System.Environment.GetCommandLineArgs
 Dim intCount As Integer
 For intCount = 0 To UBound(strStartupArguments)
 	MessageBox.Show(strStartupArguments(intCount).ToString)
 Next 'The first one is always the path&name of the application
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
probably in the form load event, the code i posted simply put's all of the commandlinearg's into it's own messagebox

you'd probably want:

VB.NET:
 if strStartupArguments(1) = "Hide Form Value" then   'remember it's a string we're dealing with
 me.hide  'hide's the form
 'or
 me.close  'closes the form
 end if
 

kobezt08

Member
Joined
Dec 30, 2004
Messages
6
Programming Experience
Beginner
ic...but wat will the whole command line be like?
1) C:\MyForm.exe "key" "dbpath"
2) C:\MyForm.exe \key \dbpath
or
3) C:\MyForm.exe "key","dbpath"
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
you should check for all cases such as
VB.NET:
  select case strStartupArguments(1)
  case "-Key"
  case "/Key"
  case "Key"
  case else
  end select
  
  select case strStartupArguments(2)
   case "-dbpath"
   case "/dbpath"
   case "dbpath"
   case else
   end select
 
Top Bottom