我必须想出一个程序来随机改变文本框中的名称。我已经把所有的东西都弄到了名字随机变化的地步。它只移动一次,但我的消息框在代码中出现的次数与单击确定后名称应移动的次数一样多。有谁知道为什么循环不适用于名称转换。我在想也许消息框需要控制循环,但我无休止地搜索,找不到怎么做。任何建议或推荐到其他网站将非常感谢。我的代码如下。
公开课形式1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim RandomNumber As Integer
Dim min, max As Integer
Dim temp, temp2, temp3, temp4, temp5, temp6 As String
Dim i As Integer
min = 3
max = 11
Randomize()
RandomNumber = Int((max - min + 1) * Rnd() + min)
temp = n1.Text
temp2 = n2.Text
temp3 = n3.Text
temp4 = n4.Text
temp5 = n5.Text
temp6 = n6.Text
For i = 0 To RandomNumber - 1
n1.Text = temp6
n2.Text = temp
n3.Text = temp2
n4.Text = temp3
n5.Text = temp4
n6.Text = temp5
MessageBox.Show("Shift " & i & " of " & RandomNumber & " complete")
Next
End Sub
结束类