[Help] Parameter Args[Solved]

Posts 1–15 of 17 · Page 1 of 2
[Help] Parameter Args[Solved]
How can I add parameters at my program to do a command?

let's say
Parameter : -opendialog
Command : Dialog1 will be shown

If I'll open my program with the parameter "-opendialog" the Dialog1 will pop-up..
Code:
Dim -OpenDialog as New OpenFileDialog
Wait.. That wasn't what you asked for was it
That is not at all what he asked for.
I don't like parameters. Sorry >_>
Simple, add this to your form's load event:


[php]For Each Argument As String In My.Application.CommandLineArgs
'Do whatever you want with your parameter.
Msgbox (Argument)
'If you have more than one parameter, then let the loop continue and check each parameter using if statement, else exit the loop.
Exit For
Next[/php]

Also have a look at the tutorial I wrote on File association and parameters:
Associate Self-Defined File Extensions To Your App

Hope this helps !!
Hassan is right.

I added my file sorter to the windows rightclick menu. When you now rightclick on a folder and hit 'File Sorter' the file sorter starts and directly searches threw the folder.





[php]Private Sub checkarguments()

Dim count As Integer
Dim x() As String = Environment.GetCommandLineArgs 'get arguments

'count all pathes
For Each s As String In x
count += 1
Next

If count > 1 Then 'not your own path
Dim path As String = x(count - 1) 'starts at index 0
Dim search As New Thread(AddressOf sid) 'call new multithread
search.Priority = ThreadPriority.Highest 'set multithreads priority
search.Start(path) 'go ahead and search threw the folder
End If

End Sub[/php]

Just call it on form_load.

Ya, there are shorter methods...but meh ^.-
Can you guys show me an example?

I didn't know where to put the argument and its command..

I'm still a beginner in making VB programs..
What exactly are you planing 2 do?

Do you want to start your program with a certain argument(with vb) or do you just want to add a parameter?

Explain.
I want to add certain parameter for my program..

just like an extractor which is like this : "C:\Users\Nathanael789\Extract.exe" -extract2

I'm creating a program with a password..

If the program will be start normally. there will be a prompt password..
but if I'll start the program with the paramter, there will be no passowrd..
To add an argument, create a shortcut of your application.

R1ghtcl1ck on it, hit properties.



To extract the arguments, see above, we have posted two codes already.

Loop threw the arguments, if one of them = "Your special argument" -> don't do anything else force password...
That is not what I meant.. I already know that..

here is supposed to be my parameter :
"C:\Users\Nathanael789\Desktop\Starter.exe" <filename>

My program will pop-up first before the program will be executed..

File.exe : as the pop-up program
<filename> : as the process will be started

Then I'll make a shortcut like that with the parameter of the file to be executed..
so my program will pop-up...
So what is your problem now?
My problem is how to get the argument of my program without the added text?

Argument : -file <filename>

Removing the "-file" in the argument and getting the filename...
so I can start the process with the argument..
Is it always -file?

If so

dim argument as string = "-file whatever"

argument = argument.replace("-file ", "")

result -> whatever

--------------------

You got the code on how to get the arguments. Using these codes and the replace function, I see no problem at all.
Oh.. I just don't understand the codes that has been given..

Thanks..
Posts 1–15 of 17 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us