run-time error 0 on shell
I have this piece of code:
code:
' Gaan updaten
If FileExist(App.Path & "\hatasalupdate2014.exe") Then
MsgBox "start updateprogram" ' just to check that the program is here
Shell (App.Path & "\hatasalupdate2014.exe"), vbNormalFocus
MsgBox "updateprogram started" '' to check if the program is so far
CmdHatasalSluiten_Click
End
End If
code:
on the shell command i get run-time error 0
What is wrong here?
Re: run-time error 0 on shell
There is no run time error o
An error number of 0 means no error occurred
1 Attachment(s)
Re: run-time error 0 on shell
DataMiser,
That's right.
But i get a message 'run-time error 0' and the program stops.
With error trapping there is nothing.
Attachment 32439
Re: run-time error 0 on shell
Does this happen when you run from the IDE? If so where does it stop and what message do you get there? Is it in the code posted or is it coming from what you are shelling?
Just as a test I tried to get VB to throw a err 0 and of course it would not do it
Err.Raise 0 throws and error as 0 is an invalid error number, trying to throw it will throw error 5 Invaild procedure call or argument
Re: run-time error 0 on shell
DataMiser,
I am a little further.
The problem is maybe not the shell command.
Executing the shell command the program hatasalupdate2014.exe starts
and stops direct with error number 5.
When i start the hatasalupdate2014.exe directly there is no problem.
Also when running from vb6 there is no problem.
Do you have any idea where the problem can be?
Re: run-time error 0 on shell
When i change the code above in:
[code]
Temp = App.Path & "\hatasalupdate2014.exe"
ShellExecute Me.hwnd, vbNullString, Temp, vbNullString, "C:\", SW_SHOWNORMAL
CmdHatasalSluiten_Click
End
[code]
it all works fine.
But i absolute have no idea why and that is something i cannot stand.
Re: run-time error 0 on shell
Code:
Shell (App.Path & "\hatasalupdate2014.exe"), vbNormalFocus
There should not be any () on that line as you are not getting a return value
If you were to use () then they need to be in a different spot.
I would be surprised if that would even compile
Re: run-time error 0 on shell
I removed the () on the shell line, but is does not make any difference.
Compiling is no problem with or without ().
Re: run-time error 0 on shell
Quote:
Originally Posted by
HermanTabbert
I removed the () on the shell line, but is does not make any difference.
Compiling is no problem with or without ().
Really?
Code:
shell (MyProgram),vbnormalfocus
I really have no idea how that would behave but it is most definitely wrong and I would expect an error to be generated by it.
This gives a compile error
Code:
shell (MyProgram,vbnormalfocus)
The correct way is either
Code:
MyResult=shell (MyProgram,vbnormalfocus)
or
Code:
shell MyProgram,vbnormalfocus
Depending on if you need to capture the result value
or if you use the out dated call keyword you can
Code:
Call shell (MyProgram,vbnormalfocus)
Re: run-time error 0 on shell
I am confused.
When i use:
Code:
Dim MyResult
MyResult = Shell(App.Path & "\hatasalupdate2014.exe", vbNormalFocus)
MsgBox "MyResult =" & MyResult
gives a run-time error 5
In hatasalupdate2014.exe i use the command to start the main program again:
Code:
Shell App.Path & "\hatasal2014.exe", vbNormalFocus
and that works ok.
I have no idea what is happening and why.
I stick to ShellExecute what works ok and go on to what i have to do.
DataMiser, if you have any solution why this happens, i would like tyo hear from you,.
For my own piece i would like this problem be solved.
Re: run-time error 0 on shell
I just tried this
Code:
Private Sub Command1_Click()
Dim MyResult
MyResult = Shell("c:\project1.exe", vbNormalFocus)
MsgBox "MyResult =" & MyResult
End Sub
Works as expected, no errors