1   1  /  1  页   跳转

VB问题(2)

VB问题(2)

算术CAI。随机出五道题,测试三位数乘法。做对一题给20分,做错不给分,每算一题,输出累计得分、测试可以循环进行。
最后编辑2007-05-06 18:26:17
分享到:
gototop
 

各位帮帮手拉!
gototop
 

程序界面如下:

附件附件:

下载次数:178
文件类型:image/pjpeg
文件大小:
上传时间:2007-4-17 22:57:45
描述:



gototop
 

以下是代码:

Dim i As Integer
Dim Fs As Integer
Dim a As Long
Dim b As Long
Dim c As Variant

Private Sub Command1_Click()
    Form1.Text7.Text = i
    If Form1.Text3.Text = c Then
        Form1.Text4.Text = "正确"
        Form1.Text5.Text = Form1.Text5.Text + 20
    Else
        Form1.Text4.Text = "错误"
    End If
   
    ClearText
    i = i + 1
    If i < 6 Then
        SetExpression
    Else
        Form1.Command1.Enabled = False
        Form1.Command2.Enabled = True
        Form1.Command3.Enabled = True
    End If

End Sub

Private Sub Command2_Click()
    Randomize
   
    i = 1
    Fs = 0
   
    Form1.Command2.Caption = "继续测试"
    Form1.Command2.Enabled = False
    Form1.Command3.Enabled = False
    Form1.Command1.Enabled = True
    Form1.Text3.Enabled = True
    Form1.Text5.Text = Fs
   
    SetExpression
   
End Sub

Private Sub Command3_Click()
    End
   
End Sub

Private Sub Form_Load()
    ClearText
    Form1.Text4.Text = ""
    Form1.Text5.Text = ""
    Form1.Text7.Text = ""
   
    Form1.Command1.Caption = "打  分"
    Form1.Command2.Caption = "开始测试"
    Form1.Command3.Caption = "退  出"
   
    Form1.Text1.Enabled = False
    Form1.Text2.Enabled = False
    Form1.Text3.Enabled = False
    Form1.Text4.Enabled = False
    Form1.Text5.Enabled = False
    Form1.Text6.Enabled = False
    Form1.Text7.Enabled = False
   
End Sub

Private Sub SetExpression()
    Form1.Text6.Text = i
    a = 0
    b = 0
    Do While a < 100 Or a >= 1000
        a = 1000 * Rnd()
    Loop
    Do While b < 100 Or b >= 1000
        b = 1000 * Rnd()
    Loop
    Form1.Text1.Text = a
    Form1.Text2.Text = b
    c = a * b
    Form1.Text3.SetFocus
   
End Sub

Private Sub ClearText()
    Form1.Text1.Text = ""
    Form1.Text2.Text = ""
    Form1.Text3.Text = ""
    Form1.Text6.Text = ""
End Sub
gototop
 

不一样的界面和方法,见笑!

附件附件:

下载次数:193
文件类型:image/pjpeg
文件大小:
上传时间:2007-5-5 18:49:06
描述:



gototop
 

Dim n As Integer, fen As Integer

Private Sub Combo1_Click()

Combo1.SelStart = Len(Combo1.Text)
n = Combo1.ListIndex
End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)
Dim chenghao As Integer, chengshu As String, beichengshu As String, fuhao As Integer, deshu As String
If KeyAscii = 13 Then
  chenghao = InStr(1, Combo1.Text, "×")
  chengshu = Left(Combo1.Text, chenghao - 1)
  fuhao = InStr(1, Combo1.Text, "=")
  beichengshu = Mid(Combo1.Text, chenghao + 1, 1)
  deshu = Right(Combo1.Text, Len(Combo1.Text) - fuhao)
  If Val(chengshu) * Val(beichengshu) = Val(deshu) Then
          fen = fen + 20
          Label2.Caption = CStr(fen)
  End If
  Combo1.AddItem Combo1.Text
  Combo1.RemoveItem n
  Combo1.SelStart = Len(Combo1.Text)
  Combo1.SetFocus
  Combo1.ListIndex = 0
 
End If
End Sub

Private Sub Command1_Click()
Dim chengshu As Integer, beichengshu As Integer, i As Integer, a As Integer
Combo1.Clear
For i = 1 To 5
  a = 899
  Randomize
  chengshu = Rnd * a + 100
  Randomize
  beichengshu = Rnd * a + 100
  Combo1.AddItem chengshu & "×" & beichengshu & "="
 
Next i


Combo1.SelStart = Len(Combo1.Text)
Combo1.SetFocus
Combo1.ListIndex = 0

End Sub

Private Sub Command2_Click()
End
End Sub


Private Sub Form_Load()
Label2.Caption = "0"
End Sub
gototop
 

做完后按出题可连续!

附件附件:

下载次数:161
文件类型:image/pjpeg
文件大小:
上传时间:2007-5-5 18:55:42
描述:



gototop
 

哇这里这么多人会编程啊
看来这里所有的斑竹都知道啊,还有厉害的哦!
gototop
 
1   1  /  1  页   跳转
页面顶部
Powered by Discuz!NT