Monday, September 6, 2010

Monday, September 6

Looking at loops again, and Michael Halvorson's tutorials.


Dim i As Integer
Dim Wrap As String
Wrap = Chr(13) & Chr(10)
For i = 1 To 11
txtLoopResultBox.Text = txtLoopResultBox.Text & "Line " & i & Wrap
Next i


I also discovered something cool for creating a pause in the program

System.Threading.Thread.Sleep(500)



Private Sub wait()
System.Threading.Thread.Sleep(500)
End Sub

Private Sub btnLoop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoop.Click

Dim i As Integer
Dim Wrap As String
Wrap = Chr(13) & Chr(10)

For i = 1 To 10 Step 1
System.Console.Beep(200, 200)
txtLoopResultBox.Text = txtLoopResultBox.Text & "Line " & i & Wrap
If i < 5 Then
wait()
Else
End If

Next i
End Sub




I finally did another modification with



Private Sub wait()
Dim waitTime As Integer
System.Threading.Thread.Sleep(waitTime)
End Sub

Private Sub btnLoop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoop.Click

Dim i As Integer
Dim Wrap As String
Wrap = Chr(13) & Chr(10)

Dim waitTime As Integer
waitTime = 600


Dim loud As Integer = 200

For i = 1 To 10 Step 1
System.Console.Beep(loud, 200)
txtLoopResultBox.Text = txtLoopResultBox.Text & "Line " & i & Wrap
If i < 5 Then
wait()
Else
loud = loud + 50
waitTime = waitTime - 100
End If


Next i
End Sub

No comments: