我无法弄清楚vb.net的代码会随机化某个计时器的间隔。对于每个a = a + 1,将存在不同的间隔,并且对于每个a = 1,a = 2,a = 3等,将在标签上显示不同的文本。
如果您知道如何使其成为可能,请提供帮助。 谢谢。
答案 0 :(得分:0)
我可能不太明白这样的事情
Dim arrLbls(3)作为标签
'带有4个类型标签元素的数组' '填充数组'
arrLbls(0) = Label1
arrLbls(1) = Label2
arrLbls(2) = Label3
arrLbls(3) = Label4
'loops trought array'
For i As Int16 = 0 To arrLbls.Length - 1
arrLbls(i).Text = "Label from the array " & i + 1
Next
`
答案 1 :(得分:0)
使用Random类
Public Function RandomNumber(ByVal MaxNumber As Integer, _
Optional ByVal MinNumber As Integer = 0) As Integer
'initialize random number generator
Dim r As New Random(System.DateTime.Now.Millisecond)
'if passed incorrect arguments, swap them
'can also throw exception or return 0
If MinNumber > MaxNumber Then
Dim t As Integer = MinNumber
MinNumber = MaxNumber
MaxNumber = t
End If
Return r.Next(MinNumber, MaxNumber)
End Function