I am going through Project Euler and I was interested to know what the time difference would be between running it on my netbook and somebody running it on a decent computer so I tried putting a timer in.
Every time I try it, the message box says that it was done in 0 seconds, but if I time it on a stopwatch I know it takes about 36 seconds.
The timer interval is 100 which is 0.1 seconds, right?
Here's my code
Code:Public Class Form1 Dim time As Decimal = 0 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim found As Boolean = False Dim i As Integer = 1 Dim ii As Integer = 1 Timer1.Start() Do Until found = True If i Mod ii = 0 Then If ii = 20 Then found = True Else : ii = ii + 1 End If Else : i = i + 1 ii = 1 End If Loop Timer1.Stop() MsgBox("The number " & i & " was found in " & time & " seconds") End Sub Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick time = time + 0.1 End Sub End Class




Reply With Quote
