急切求助用VB编一个小学算术出题系统

2025-04-19 19:22:08
推荐回答(1个)
回答1:

我帮你多实现了一个功能,就是一共给两次机会

第一次算错之后,确认按钮变成再来,你不想要可以自行去掉

你也确实挺抠的·一分都不给·我就当玩了

Dim jieguo As Integer, shu1 As Integer, shu2 As Integer, dui As Integer, cuo As Integer

Private Sub Command1_Click()

Option1.Value = False

Option2.Value = False

Option3.Value = False

Option4.Value = False

Option5.Value = False

If Command1.Caption = "再来" Then

 

  If Val(Text1.Text) = jieguo Then

  Picture1.Print Label1.Caption; Text1; "√ 这么牛!"

  dui = dui + 1

  Else

  Picture1.Print Label1.Caption; Text1; "(正确答案"; jieguo; ")"; "× 我靠 鄙视你!"

  cuo = cuo + 1

  End If

  Command1.Enabled = False

 End If

If Command1.Caption = "确认" Then

   If Val(Text1.Text) = jieguo Then

  Picture1.Print Label1.Caption; Text1; "√ 这么牛!"

  dui = dui + 1

  Else

  Text1.Text = ""

  Text1.SetFocus

  Picture1.Print "你敢再做一遍呗!"

  Command1.Caption = "再来"

  End If

 End If

 Text1.Text = ""

End Sub

Private Sub Command2_Click()

Picture1.Print "★★★★★★★哥给你算算多少分★★★★★★★"

Picture1.Print "你一共做了"; (dui + cuo); "道题"

If dui + cuo <> 0 Then

Picture1.Print "你得了"; Int(dui / (dui + cuo) * 100); "分"

End If

End Sub

Private Sub Form_Load()

Option1.Value = False

Option2.Value = False

Option3.Value = False

Option4.Value = False

Option5.Value = False

End Sub

Private Sub Option1_Click()

    Command1.Caption = "确认"

    Command1.Enabled = True

    Text1.FontSize = 18

    Randomize

    shu1 = Int(Rnd * 100 + 1)

    shu2 = Int(100 * Rnd + 1)

    jieguo = shu1 + shu2

    Label1.Caption = shu1 & "+" & shu2 & "="

    Label1.FontSize = 18

End Sub

Private Sub Option2_Click()

    Command1.Caption = "确认"

    Command1.Enabled = True

    Dim t As Integer

    Text1.FontSize = 18

    Randomize

    shu1 = Int(Rnd * 100 + 1)

    shu2 = Int(100 * Rnd + 1)

    If shu1 < shu2 Then

        t = shu1

        shu1 = shu2

        shu2 = t

    End If

    jieguo = shu1 - shu2

    Label1.Caption = shu1 & "-" & shu2 & "="

    Label1.FontSize = 18

End Sub

Private Sub Option3_Click()

Command1.Caption = "确认"

    Command1.Enabled = True

Text1.FontSize = 18

    Randomize

    shu1 = Int(Rnd * 100 + 1)

    shu2 = Int(100 * Rnd + 1)

    jieguo = shu1 * shu2

    Label1.Caption = shu1 & "×" & shu2 & "="

    Label1.FontSize = 18

End Sub

Private Sub Option4_Click()

Command1.Caption = "确认"

    Command1.Enabled = True

    Dim t As Integer

    Text1.FontSize = 18

    Randomize

    shu1 = Int(Rnd * 100 + 1)

    shu2 = Int(100 * Rnd + 1)

    If shu1 < shu2 Then

        t = shu1

        shu1 = shu2

        shu2 = t

    End If

    If shu1 Mod shu2 <> 0 Then

       shu1 = shu1 - shu1 Mod shu2

    End If

    jieguo = shu1 / shu2

    Label1.Caption = shu1 & "÷" & shu2 & "="

    Label1.FontSize = 18

End Sub

Private Sub Option5_Click()

Command1.Caption = "确认"

    Command1.Enabled = True

    Dim t As Integer

    Dim suijishu As Integer, fuhao As String * 1

    Text1.FontSize = 18

    Randomize

    shu1 = Int(Rnd * 100 + 1)

    shu2 = Int(100 * Rnd + 1)

    If shu1 < shu2 Then

        t = shu1

        shu1 = shu2

        shu2 = t

    End If

    suijishu = Int(Rnd * 4 + 1)

    Select Case suijishu

        Case 1

          fuhao = "+"

          jieguo = shu1 + shu2

        Case 2

         fuhao = "-"

         jieguo = shu1 - shu2

        Case 3

         fuhao = "*"

         jieguo = shu1 * shu2

        Case 4

        If shu1 Mod shu2 <> 0 Then

          shu1 = shu1 - shu1 Mod shu2

        End If

         fuhao = "/"

         jieguo = shu1 / shu2

     End Select

     Label1.Caption = shu1 & fuhao & shu2 & "="

     Label1.FontSize = 18

End Sub