首页 > 技术文章 > 班级随机点名程序

daveylin 2020-06-18 19:04 原文

一、界面设计

对象名 属性名 属性值
Form1 Caption 随机点名
Label2 Caption 班级人数
Label2 FontSize 12
Text1 Text 请输入班级人数
Text1 FontSize 12
Label1 Caption ""
Label1 FontSize 72
Command1 Caption 点名
Command1 FontSize 12

 

二、程序代码

Dim num As Integer  'num表示班级人数

Private Sub Command1_Click()
  num = Val(Text1.Text)
  If num <= 0 Then
    MsgBox ("请输入班级人数")
  Else
    Randomize
    xh = Int((num * Rnd) + 1)
    Label1.Caption = Str(xh)
  End If
End Sub

Private Sub Text1_Click()
  Text1.Text = ""
End Sub

 

推荐阅读