need help pausing in visual basic .net

dbzwukan

Senior member
Dec 17, 2001
532
0
0
writing my first project, it's a slot machine. with fruits... very basic.. and should be very easy....
did everything... except that when the wheels are spinning, it is spinning too face that you only get
to see the final bmp. is there anyway i can pause it like 400 milliseconds for each new .bmp when it is
spinning?



here's what i tried so far (not in code format, just a general idea)

something like converting the current time to milliseconds... add 500 to it (newtime) and do
a while current.milliseconds < newtime
do nothing
end while loop

for some reason, that didn't work... the program just stopped cold.

i tried to look up the timer function.. but the example in the help didn't work. perhaps i'm doing something wrong.
( when i did a start = timer ) the errors says timers is a type and can't be used as an expression. or something like that.

anyone?
 

XZeroII

Lifer
Jun 30, 2001
12,572
0
0
Dim x as integer
for x = 0 to 100000000
next


it's the old fashioned way of doing it. It doesn't scale well, but it will give you the effect you are looking for.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
and you people say Perl is ugly. Visual Basic looks like ENGLISH.

programming languages are suppsoed to have semicolons and square brackets and stuff.
 

Descartes

Lifer
Oct 10, 1999
13,968
0
0
Dim x as integer
for x = 0 to 100000000
next


it's the old fashioned way of doing it. It doesn't scale well, but it will give you the effect you are looking for.
Yikes!!!

That's really a bad way of implementing that. My example of Thread.Sleep() will suit his needs just fine. One can also use Sleep() or SleepEx() from the win32 api as well. Using a for loop like that is bad for the following reasons:

1) It's not deterministic. In a preemptive multitasking OS, the thread executing this loop could be interrupted at any time, so how long it sleeps is entirely non-deterministic. This is obviously a bad thing.
2) In VB, the above code will completely block thread execution due to VB's threading architecture. You should at least throw in a DoEvents, but that still doesn't make it right.
3) In programming, such arbitrary implementations (read: guesses) at behavior is called "programming by coincidence", as you don't really know what's going to happen given the current operating environment.

So... in .NET, Thread.Sleep(). In the win32 api, Sleep() or SleepEx().

and you people say Perl is ugly. Visual Basic looks like ENGLISH.

programming languages are suppsoed to have semicolons and square brackets and stuff.
Yah, and Perl flows like english.

open(FILE, ">something") || die "hmm?";

I do hate VB's syntax though, always have. It's become even more verbose with VB.NET. *shrug* I still like VB for it's other merits, though...
 

XZeroII

Lifer
Jun 30, 2001
12,572
0
0
very true, but that was actually the way we learned to do it in school (Yea, I know). I'm just saying that my way is a very quick way to do this if you arn't writing a professional application. I've never played with the threads so I don't know about the sleep routines. I'll have to check that stuff out.
 

ASK THE COMMUNITY