|
-
Sep 14th, 2000, 07:31 AM
#1
I am working with VB 6.0 and I need to know how to make a program exit with a determined return code. In C it would be as simple as writing exit(-1) in the Main function, but I can not find the equivalent in VB. Thank you.
-
Sep 14th, 2000, 07:49 AM
#2
_______
<?>
Code:
'a walk around..need If x..in any place you might
'change x
Option Explicit
Public x As Boolean
Private Sub Command1_Click()
' all your code
'if requirements are met change value x
x = True
If x = True Then Call UnloadAll
End Sub
Public Sub UnloadAll()
'unload all forms
Dim frm As Form
Dim i As Integer
For i = 1 To Forms.Count - 1
Unload frm
Set frm = Nothing
Next i
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 14th, 2000, 09:07 AM
#3
transcendental analytic
I think you have to modify this Hesaidjoe:
Code:
For i = 1 To Forms.Count - 1
Unload frm
Set frm = Nothing
Next i
into this:
Code:
For each frm in Forms
Unload frm
Set frm = Nothing
Next frm
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Sep 14th, 2000, 09:14 AM
#4
Guru
Guys, what about the exit code? 
Code:
' General Declarations:
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
Then, use ExitProcess like you would use exit in C.
Code:
Call ExitProcess(-1)
You should do that after unloading all the forms...
Code:
Dim Form As Form
For Each Form In Forms
Call Unload(Form)
Set Form = Nothing
Next
' ExitProcess here
-
Sep 14th, 2000, 09:15 AM
#5
Not exactly what I needed!
I want to exit the VB program with a value (for example 2) so that another program or the Operative System can get that value when the VB program finishes execution.
My VB program will have a Sub Main () as the initial point.
In C what I want could be done with:
void main()
{
exit(2) //Or whatever value you want to return to the OS
}
Thank you.
-
Sep 14th, 2000, 09:33 AM
#6
Thank you all
Finally Yonatan solved my doubt. Thanks everyone.
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
|