发布网友 发布时间:2023-12-24 07:34
共2个回答
热心网友 时间:2024-08-28 22:59
Option Base 1
Dim RName() As String
Dim CurrentI As Integer
Public NameMax As Integer
Private Sub CmdStart_Click()
If CmdStart.Caption = "Start" Then
If NameMax = 0 Then
MsgBox "随机选择结束", vbOKOnly + vbInformation, "提示"
Exit Sub
End If
CmdStart.Caption = "Stop"
Timer1.Enabled = True
Else
CmdStart.Caption = "Start"
Timer1.Enabled = False
RichTextBox1.Text = RichTextBox1.Text + vbCrLf + RName(CurrentI)
If NameMax > 0 Then
RName(CurrentI) = RName(NameMax)
NameMax = NameMax - 1
End If
End If
End Sub
Private Sub Form_Load()
NameMax = 4
ReDim RName(NameMax)
RName(1) = "张三"
RName(2) = "李四"
RName(3) = "王二"
RName(4) = "有几个加几个"
End Sub
Private Sub Timer1_Timer()
Randomize
CurrentI = Fix(Rnd * NameMax) + 1
Label1.Caption = RName(CurrentI)
DoEvents
Label1.Refresh
Form1.Refresh
End Sub
以上是代码,附件里有工程文件,可以满足你的要求,姓名可以保证在程序里,不容易被修改,用的都是常用控件,richtextbox控件应该也有吧,如果没有,用textbox也一样
热心网友 时间:2024-08-28 22:56
你要用来干什么?数据需不需要保存?