[转载]使用VB制作一个摇奖系统
文章作者:Siqi Wu使用For-Next循环产生1000个1-100之间的随即整数.
首先在窗体上设计一个文本框(Text1)和一个按钮(Command1),上面打上“开始抽奖”,这样按这个键就开始抽奖。
[code]Private Sub Command
Dim intranum As Integer,i As Integer,j As Integer,A As Integer
Randomize
For j = 1 To 1000
intranum = Int(100 * Rnd) + 1
a = 0
For j = 1 To 10000
a = a + 1
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
Next i
Text1.Text = CStr(intranum)
End Sub[/code] 编译错误:
For control控件变量已在使用..
我直接新建了一个text和Command控件...编译不成
是不是还需要别的什么啊 [quote][b]这里是引用第[/b][color=#ff0000][2 楼][/color][b]的[color=#000066]fhod[/color]于[/b]2005-12-15 20:54[b]发表的:[/b]
编译错误:
For control控件变量已在使用..
我直接新建了一个text和Command控件...编译不成
是不是还需要别的什么啊[/quote]
For j = 1 To 1000
第一个是i,不是j。 我在运行的时候发现 TEXT里面什么都不显示,这个是什么原因? Private Sub Command_Click()
Dim intranum As Integer, i As Integer, j As Integer, A As Integer
Randomize
For i = 1 To 1000
intranum = Int(100 * Rnd) + 1
A = 0
For j = 1 To 10000
A = A + 1
Next j
Text1.Text = CStr(intranum)
Text1.Refresh
Next i
Text1.Text = CStr(intranum)
End Sub
这样编译就成功了。
页:
[1]