r/visualbasic • u/W0CBF • 2d 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!
4
Upvotes
12
u/Due-Mortgage-6854 2d ago edited 2d 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)2
u/mika 2d ago
You're probably thinking of Debug.Assert but I think Stop also works
2
u/Cdream-2018 2d 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
u/JuanPabloElSegundo 2d ago
You show a message box and tell the user to close it after X seconds.
2
u/Mayayana 2d 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
u/OkSignificance5380 2d ago
lookup DoEvents ()
1
u/zero_dr00l 1d ago
Stop?
1
u/Belasius1975 1d ago
me.sleep
1
u/DaveX64 1d ago
I used to use the 'DoEvents' keyword for that...here's an example google coughed up: