Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Val(TextBox5.Text) = 0 Then
TextBox5.Text = 0
End If
TextBox5.Text = TextBox5.Text + 1
Dim percent As Double
percent = (TextBox3.Text)/100
Dim value As Integer = Integer.Parse(TextBox1.Text)
Dim flag As Integer = 0
Dim count As Integer = 0
Do While count < value
Dim rnd = New Random()
Dim nextValue = rnd.Next(100)/100
If nextValue < percent Then
flag = flag + 1
End If
count = count + 1
Loop
TextBox6.Text = value - flag
End Sub
如果我一步步調試控制進入循環我的代碼工作正常。 但是,當我執行它直接控制不會在去循環代碼沒有進入For循環或做while循環
在循環中放置一個斷點並按F5確認執行命中循環。 – Senthil 2015-04-05 03:09:55
如果存在中斷點,則執行命中循環。但是,一旦我刪除了中斷點,它不會觸及循環。 – meghan 2015-04-05 03:40:28
這意味着它在執行時間內工作正常。可能是一些邏輯問題,不能按照您的預期解決結果。檢查你的邏輯和非常天真 – Senthil 2015-04-05 03:43:49