一、界面設計

| 對象名 | 屬性名 | 屬性值 |
| 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
