-
March 13th, 2014, 05:20 AM
#1
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?
-
March 13th, 2014, 10:09 AM
#2
Re: run-time error 0 on shell
There is no run time error o
An error number of 0 means no error occurred
Always use [code][/code] tags when posting code.
-
March 13th, 2014, 11:55 AM
#3
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.
-
March 13th, 2014, 12:04 PM
#4
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
Always use [code][/code] tags when posting code.
-
March 14th, 2014, 05:17 AM
#5
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?
-
March 14th, 2014, 05:38 AM
#6
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.
-
March 14th, 2014, 09:50 AM
#7
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
Always use [code][/code] tags when posting code.
-
March 14th, 2014, 12:15 PM
#8
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 ().
-
March 14th, 2014, 01:01 PM
#9
Re: run-time error 0 on shell
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)
Last edited by DataMiser; March 14th, 2014 at 01:05 PM.
Always use [code][/code] tags when posting code.
-
March 15th, 2014, 05:04 AM
#10
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.
-
March 15th, 2014, 10:01 AM
#11
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
Always use [code][/code] tags when posting code.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|