⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tm.frm

📁 英语测试
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frm 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "出题测试"
   ClientHeight    =   3915
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   7635
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   3915
   ScaleWidth      =   7635
   StartUpPosition =   1  '所有者中心
   Begin VB.OptionButton opi 
      BackColor       =   &H00C0FFFF&
      Height          =   375
      Index           =   4
      Left            =   0
      TabIndex        =   5
      Top             =   2400
      Width           =   7695
   End
   Begin VB.CommandButton comnext 
      Caption         =   "next->"
      Height          =   495
      Left            =   3000
      TabIndex        =   4
      Top             =   3240
      Width           =   1935
   End
   Begin VB.OptionButton opi 
      BackColor       =   &H00C0FFFF&
      Height          =   375
      Index           =   3
      Left            =   0
      TabIndex        =   3
      Top             =   1800
      Width           =   7695
   End
   Begin VB.OptionButton opi 
      BackColor       =   &H00C0FFFF&
      Height          =   375
      Index           =   2
      Left            =   0
      TabIndex        =   2
      Top             =   1200
      Width           =   7695
   End
   Begin VB.OptionButton opi 
      BackColor       =   &H00C0FFFF&
      Height          =   375
      Index           =   1
      Left            =   0
      TabIndex        =   1
      Top             =   600
      Width           =   7695
   End
   Begin VB.Label lab 
      AutoSize        =   -1  'True
      BackColor       =   &H00C0FFFF&
      BeginProperty Font 
         Name            =   "楷体_GB2312"
         Size            =   14.25
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   150
   End
End
Attribute VB_Name = "frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim total(5) As String
Dim ss(3) As String
Dim s(4) As String
Dim i As Integer
Dim strTem As String
Dim intTem As Integer
Dim str(1 To 4) As String
Dim hm(1 To 4) As String
Dim e As String
Private Sub zongji()
        total(0) = 0
        Open App.Path & "\英语题库.txt" For Input As #1 '打开题库
        Do Until EOF(1) '用循环来判断题库的行数
           total(0) = total(0) + 1
           Line Input #1, e
        Loop
        Close
        'MsgBox total(0)
        Call dcrnd '呼叫
End Sub

Private Sub comnext_Click()
        Call pdzw
        Call zongji
        Call xjjs1
        strTem = ""
        Call xjjs2
        Call xjjs3
        Call dl
End Sub
Private Sub dcrnd()
        Randomize '使每次的随机数都不同
        total(1) = 0
        total(1) = Int(Rnd * (total(0) - 1 + 1)) + 1
        Do Until total(1) Mod 2 <> 0 '判断得到的随机数是否为单数,因为题库单数行是单词,双数行是解释
           total(1) = Int(Rnd * (total(0) - 1 + 1)) + 1 '如果不是单数,重新抽选
        Loop
        'MsgBox total(1)
        Call zqdc
End Sub
Private Sub zqdc()
        i = 0
        Open App.Path & "\英语题库.txt" For Input As #1
        Do While Not EOF(1) And i < total(1) '读取上一个过程得到的行数的字符,也就是读取出正确的单词
           Line Input #1, s(0)
           i = i + 1
        Loop
        'MsgBox s(0)
        lab.Caption = s(0) '把读取到的单词赋值给lab的capiton属性
        Close #1
        Call zqjs
End Sub
Private Sub zqjs()
        i = 0
        total(2) = 0
        s(1) = ""
        total(2) = total(1) + 1 '得到单词的正确解释所在的行数
        '因为题库里面,如果n为单数,第n行是一个单词,那么n+1行就是这个单词的解释
        Open App.Path & "\英语题库.txt" For Input As #1
        Do While Not EOF(1) And i < total(2) '读取单词的正确解释
           Line Input #1, s(1)
           i = i + 1
        Loop
       ' MsgBox s(1)
        Close #1
End Sub
Private Sub xjjs1()
        Randomize '是每次得到的随机数都不同
        i = 0
        s(2) = ""
        total(3) = Int(Rnd * (total(0) - 1 + 1)) + 1
        Do Until total(3) Mod 2 = 0 '判断得到的随机数是否为双数,因为在题库里面双数行表示的是解释
           total(3) = Int(Rnd * (total(0) - 1 + 1)) + 1 '如果不是重新抽取
        Loop
        Open App.Path & "\英语题库.txt" For Input As #1
        Do While Not EOF(1) And i < total(3) '读取得到的虚假解释
           Line Input #1, s(2)
           i = i + 1
        Loop
        Close #1
        '下面的xjjs2和xjjs3过程同理,都是产生虚假的解释
        'MsgBox s(2)
End Sub
Private Sub xjjs2()
        Randomize '使每次所得到的随机数都不同
        i = 0
        's(3) = ""
        total(4) = Int(Rnd * (total(0) - 1 + 1)) + 1
        Do Until total(4) Mod 2 = 0
           total(4) = Int(Rnd * (total(0) - 1 + 1)) + 1
        Loop
        Open App.Path & "\英语题库.txt" For Input As #1
        Do While Not EOF(1) And i < total(4)
           Line Input #1, s(3)
           i = i + 1
        Loop
        Close #1
        'MsgBox s(3)
End Sub
Private Sub xjjs3()
        Randomize
        i = 0
        s(4) = ""
        total(5) = Int(Rnd * (total(0) - 1 + 1)) + 1
        Do Until total(5) Mod 2 = 0
           total(5) = Int(Rnd * (total(0) - 1 + 1)) + 1
        Loop
        Open App.Path & "\英语题库.txt" For Input As #1
        Do While Not EOF(1) And i < total(5)
           Line Input #1, s(4)
           i = i + 1
        Loop
        Close #1
        'MsgBox s(4)
End Sub
Private Sub dl() '把得到的正确解释和虚假解释打乱的过程
       i = 0
      Do '这个算法是我在VB吧中找到的,这里希望作者不会介意
          intTem = Int(Rnd * (4 - 1 + 1)) + 1 '产生1-4的随机数,并且把随机数赋值给intTem
          If InStr(1, strTem, CStr(intTem)) = 0 Then '用InStr函数来判断是否得到的随机数有重复
              strTem = strTem & CStr(intTem) '把已有的strTem和intTem合并成一个值
              i = i + 1 '把用来判断随机数是否满4个的值
             If i > 3 Then Exit Do '如果随机数满4个就退出循环
          End If
      Loop
      str(1) = Mid(strTem, 1, 1) '因为在判断是否有重复随机数的时候把所得到的随机数合并成一个字符串了,所以这里要分割
      str(2) = Mid(strTem, 2, 1)
      str(3) = Mid(strTem, 3, 1)
      str(4) = Mid(strTem, 4, 1)
          i = 0
      For i = 1 To 4 '把分割了的字符赋值给变量hm()
         hm(i) = CInt(str(i))
      Next i
      i = 0
      For i = 1 To 4 '把hm()的值赋值给单元框的capiton属性
          opi(hm(i)).Caption = s(i)
      Next i
End Sub

Private Sub pdzw() '判断答案是否正确
        i = 0
        For i = 1 To 4
            If opi(i).Value = True Then
               If CStr(opi(i).Caption) = s(1) Then MsgBox "答案正确"
            ElseIf opi(i).Value = False And CStr(opi(i).Caption) = s(1) Then
               MsgBox "答案错误,正确答案是:" & s(1)
            End If
        Next i
        
End Sub

Private Sub Form_Load() '窗体加载时
        Call zongji
        strTem = ""
        Call xjjs1
        Call xjjs2
        Call xjjs3
        Call dl
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -