English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

設計程式,由接受測驗者點選答案,每題計50分,答錯一提到扣20分,並顯示得分,(最少為0分)會的請麻煩給我一下程式碼^^

2006-01-22 03:32:46 · 1 個解答 · 發問者 泰迪熊 3 in 電腦與網際網路 程式設計

1 個解答

以下是十個加法算數考題,設個表單直接把程式碼貼上就可XD
Dim A As Label, T, X, Y, R As Boolean, WithEvents B As CheckBox, WithEvents C As CheckBox

Private Sub B_Click()
If B Then Chk B.Caption
End Sub
Sub Chk(S)
If Val(S) = X + Y Then
T = T + 50
MsgBox "你答對了"
Else
T = T - 20
If T < 0 Then T = 0
MsgBox "你答錯了"
End If
R = True
End Sub

Private Sub C_Click()
If C Then Chk C.Caption
End Sub

Private Sub Form_Activate()
Dim I
Randomize
For I = 1 To 10
R = False
X = Int(Rnd * 100) + 1
Y = Int(Rnd * 100) + 1
A = X & "+" & Y
If (Int(Rnd * 10) + 1) Mod 2 = 0 Then
B.Caption = X + Y: C.Caption = Int(Rnd * 10) + X + Y + 1
Else
C.Caption = X + Y: B.Caption = Int(Rnd * 10) + X + Y + 1
End If
Do
DoEvents
Loop Until R
B = 0: C = 0
Next
MsgBox "你的分數是 : " & T & "分"
End Sub

Private Sub Form_Load()
Set A = Controls.Add("VB.Label", "A")
A.Width = ScaleWidth: A.Visible = True
Set B = Controls.Add("VB.CheckBox", "B")
B.Top = A.Top + A.Height + 20: B.Visible = True
Set C = Controls.Add("VB.CheckBox", "C")
C.Top = B.Top: C.Left = B.Left + B.Width + 10: C.Visible = True
End Sub

2006-01-22 13:07:46 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers