PC Review


Reply
Thread Tools Rate Thread

argument question

 
 
romy
Guest
Posts: n/a
 
      7th Aug 2005
Hi


How do I use external argument in vb.net ?

for example I want to open a form by its argument

myprog.exe 1 -> open form1
myprog.exe 2 -> open form2.
.....


 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      7th Aug 2005
>How do I use external argument in vb.net ?

Something like this:

Shared Sub Main(ByVal args() As String)

Dim f As Form
If args(0) = "1" Then
f = New Form1
ElseIf args(0) = "2" Then
f = New Form2
End If
Application.Run(f)

End Sub



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      7th Aug 2005
"romy" <(E-Mail Removed)> schrieb:
> How do I use external argument in vb.net ?
>
> for example I want to open a form by its argument
>
> myprog.exe 1 -> open form1
> myprog.exe 2 -> open form2.


\\\
Public Module Program
Public Sub Main(ByVal Args() As String)
If Args.Length > 0 Then
Dim MainForm As Form
Select Case Args(0)
Case "1"
MainForm = New Form1()
Case "2"
MainForm = New Form2()
Case Else
Return
End Select
Application.Run(MainForm)
End If
End Sub
End Module
///

Don't forget to select 'Sub Main' as startup object in the project
properties dialog.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
Dragon
Guest
Posts: n/a
 
      7th Aug 2005
Hi,

In addition to Mattias & Herfried, you can access command line arguments
outside Main() by Shared Environment.CommandLine and
Environment.GetCommandLineArgs().

Roman
"romy" <(E-Mail Removed)> ñîîáùèë/ñîîáùèëà â íîâîñòÿõ ñëåäóþùåå:
news:(E-Mail Removed)...
> Hi
>
>
> How do I use external argument in vb.net ?
>
> for example I want to open a form by its argument
>
> myprog.exe 1 -> open form1
> myprog.exe 2 -> open form2.
> ....
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Function Argument Question WAR Microsoft Excel Misc 4 26th Apr 2010 06:04 PM
User function argument question Richard Ahlvin Microsoft Excel Programming 4 22nd Sep 2005 02:40 PM
Function (array argument, range argument, string argument) vba Witek Microsoft Excel Programming 3 24th Apr 2005 03:12 PM
Argument question in a macro ginger Microsoft Access External Data 1 3rd Aug 2004 01:22 AM
question re: Me! argument John G Microsoft Access Form Coding 5 21st Jul 2003 06:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:23 PM.