Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have passed the arguments from the command prompt to the form, i want to know the type of that arguments i passed, how to write code for that in vb.net

What I have tried:

i tried for this code

if Environment.GetCommandLineargs(1).GetType
\\i have to check whether this argument is decimal or not
Posted
Updated 20-Feb-17 1:01am

The arguments are always a string. If you want to see if that string can be converted to a decimal then use Decimal.TryParse[^]
 
Share this answer
 
Comments
Member 13012003 20-Feb-17 7:33am    
Thanq...
When you fetch command line arguments, they are always strings: they are "what the user typed on the command line to execute your application" - and you can supply them that way by opening a command prompt and typing the name of your app followed by space-separated parameters:
myApp Parameter1 "parameter 2 with spaces in"
As such, they don't have a type in the sense of "integer" or "decimal".
Use TryParse to check them:
VB
Dim value As Decimal
If Not Decimal.TryParse(Environment.GetCommandLineargs(1), value) Then
	' Report problem to user.
        ...
	Return
End If
 
Share this answer
 
Comments
Member 13012003 20-Feb-17 7:33am    
Thanq. now its working fine...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900