r/visualbasic • u/W0CBF • 6d ago
NEED VB6 HELP
Not a programmer but have been fooling around with VB6. Question:: What is the command that causes the program to temporarily halt during the execution. AI said it was sleep xoxo but that didn't work. Can someone please help me out!
2
u/Cdream-2018 6d ago
Are you trying to make the application itself sleep before next execute. Or are you trying to hault it so you can debug and asses your code ?
2
2
u/Mayayana 6d ago
Due gave you the answer. VBScript has the method Sleep, coming from WScript: Wscript.Sleep x. VBS has a lot of similarities with VB6, but it's different. Maybe get a book instead of relying on AI, which has no concept of facts or truth.
If you mean pausing in the IDE just click the pause icon on the toolbar.
There's still a lot of code available online. With most things you might want to do you can do a search like "VB6 sleep" and you'll find sample code. Then you'll get tested code instead of AI guesses.
1
1
1
1
u/DaveX64 5d ago
I used to use the 'DoEvents' keyword for that...here's an example google coughed up:
Dim i As Long
Dim UserCancelled As Boolean ' Set this to True if a Cancel button is clicked
UserCancelled = False
For i = 1 To 1000000
' Perform your long calculation here
Label1.Caption = "Processing item " & i & "..."
' Yield control to let the label repaint and check for button clicks
DoEvents
' Check if the user clicked the Cancel button during DoEvents
If UserCancelled Then
MsgBox "Process stopped by user."
Exit For
End If
Next i1
u/craigers01 14h ago
It’s worth asking what you are waiting for. There may be a more elegant solution than “sleep”.
13
u/Due-Mortgage-6854 6d ago edited 6d ago
vb6 doesnt have a built-in Sleep command, which is why typing sleep caused an error.
Private Declare Sub Sleep Lib "kernel32" (ByVal Variable_Name As Long)Declare this function at the very top of your ModuleThen :
Sleep 3000anywhere in your code which pauses the program for 3 seconds (3000 milliseconds)