Please explain what is occuring in this routine

R

Ryan

I am learning and I have a form, basically a splash screen, that load with
this code. t is a public int = 0 from a module

Me.Show()

Dim i

i = Now.Ticks

Do While (i + 50000000) > Now.Ticks

Application.DoEvents()

t = t + 1

Loop

Me.Dispose()

Next my sub main calls the main form with a label on it that displays t. t
is a different value each time.

Why is t different each time? Maybe I am misunderstand what now.ticks do?

Thanks!
 
C

Cor

Hi Ryan,

Now is the time Now so it is always the time Now + 50000000 etc.

Nothing wrong with of course, but your program consumes totally the
processor,

Beneath a sample with a timer.

I hope this helps?

Cor

\\\form1 the main form
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim frm As New Form2
frm.ShowDialog()
frm.Dispose()
End Sub
///
\\\splash screen is form2
ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "High I Am Here"
timer1.Enabled = True
timer1.Interval = 25
Me.Opacity = 0
Me.Text = "Splash"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles timer1.Tick
Me.Opacity += 0.01
If Me.Opacity = 1 Then
Me.Close()
End If
End Sub
////
 
R

Ryan

Yes. Worked good. Thanks!


Cor said:
Hi Ryan,

Now is the time Now so it is always the time Now + 50000000 etc.

Nothing wrong with of course, but your program consumes totally the
processor,

Beneath a sample with a timer.

I hope this helps?

Cor

\\\form1 the main form
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim frm As New Form2
frm.ShowDialog()
frm.Dispose()
End Sub
///
\\\splash screen is form2
ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "High I Am Here"
timer1.Enabled = True
timer1.Interval = 25
Me.Opacity = 0
Me.Text = "Splash"
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles timer1.Tick
Me.Opacity += 0.01
If Me.Opacity = 1 Then
Me.Close()
End If
End Sub
////
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top