Command Help

Azreal

Member
Joined
Oct 4, 2006
Messages
19
Programming Experience
Beginner
Hello, I am using Visual Basic 2005 Express, and I am having some trouble with the Command function. I want a picturebox to load a picture from the command, but it always fails giving me an error. I use image.fromfile(Command) but the command has quotation marks around it. This is what causes the errors. I was wondering how I would remove the quotation marks around the command.
 
I'm sorry I should have been more clear. When my program starts it checks to see if it has a command sent from windows.

Form Load Procedure:

If Command() = "" then
Exit Sub
Else
' Open the picture
img.Image = Image.FromFile(Command())
End If
 
hi,

ok, not sure if i can help you with your problem i need to think about it a bit more, but i think you should avoid exit sub like the plauge. its better to just not do anything (or use a not (if bla bla bla)) to avoid using the exit sub. depending on how you code your project, sometimes you can miss things that needed to be executed because you exited the sub before it had a chance to finish


good luck
regards
adam
 
I have found the answer I was looking for by messing around with the code. Thanks for all of your help and your advice :)
 
So you're talking about commandline arguments. If you aren't already using something like this, the standard way to get commandline arguments in VB.NET is:
VB.NET:
Dim cla As String() = Environment.GetCommandLineArgs()

'The first element is always the executable path itself.
If cla.Length > 1 Then
    'The application did receive commandline arguments.
    For i As Integer = 1 To cla.GetUpperBound(0)
        MessageBox.Show(cla(i))
    Next i
End If
 
Back
Top