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

📄 打字.frm

📁 简单的打字练习程序,可自定义练习的文章
💻 FRM
字号:
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "richtx32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.OCX"
Begin VB.Form Form2 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Form2"
   ClientHeight    =   7635
   ClientLeft      =   1035
   ClientTop       =   1110
   ClientWidth     =   9405
   ControlBox      =   0   'False
   LinkTopic       =   "Form2"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   7635
   ScaleWidth      =   9405
   ShowInTaskbar   =   0   'False
   WhatsThisHelp   =   -1  'True
   Begin VB.CheckBox settime 
      Caption         =   "自定义时间"
      Height          =   375
      Left            =   7800
      Style           =   1  'Graphical
      TabIndex        =   11
      Top             =   120
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Height          =   735
      Left            =   120
      TabIndex        =   2
      Top             =   0
      Width           =   5535
      Begin VB.PictureBox exit1 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H80000005&
         ForeColor       =   &H80000008&
         Height          =   510
         Left            =   4680
         Picture         =   "打字.frx":0000
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   12
         Top             =   120
         Width           =   510
      End
      Begin VB.ComboBox time2 
         Height          =   300
         ItemData        =   "打字.frx":0442
         Left            =   3240
         List            =   "打字.frx":0452
         TabIndex        =   3
         Top             =   240
         Width           =   975
      End
      Begin VB.Label xm2 
         Caption         =   "姓名"
         Height          =   375
         Left            =   120
         TabIndex        =   8
         Top             =   240
         Width           =   615
      End
      Begin VB.Label xm3 
         Height          =   375
         Left            =   840
         TabIndex        =   7
         Top             =   240
         Width           =   735
      End
      Begin VB.Label xh2 
         Caption         =   "学号"
         Height          =   375
         Left            =   1680
         TabIndex        =   6
         Top             =   240
         Width           =   495
      End
      Begin VB.Label xh3 
         Height          =   375
         Left            =   2400
         TabIndex        =   5
         Top             =   240
         Width           =   615
      End
      Begin VB.Label time1 
         Height          =   375
         Left            =   3360
         TabIndex        =   4
         Top             =   240
         Width           =   735
      End
   End
   Begin VB.Timer Timer1 
      Interval        =   1000
      Left            =   8880
      Top             =   480
   End
   Begin VB.CommandButton op 
      Caption         =   "打开"
      Height          =   375
      Left            =   6840
      TabIndex        =   1
      Top             =   120
      Width           =   855
   End
   Begin VB.CommandButton zhanting 
      Caption         =   "暂停"
      Height          =   375
      Left            =   5880
      TabIndex        =   0
      Top             =   120
      Width           =   735
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   8880
      Top             =   1200
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin RichTextLib.RichTextBox RichTextBox1 
      Height          =   3375
      Index           =   1
      Left            =   120
      TabIndex        =   9
      Top             =   4080
      Width           =   9135
      _ExtentX        =   16113
      _ExtentY        =   5953
      _Version        =   393217
      TextRTF         =   $"打字.frx":0465
   End
   Begin RichTextLib.RichTextBox RichTextBox1 
      Height          =   3375
      Index           =   0
      Left            =   120
      TabIndex        =   10
      Top             =   720
      Width           =   9135
      _ExtentX        =   16113
      _ExtentY        =   5953
      _Version        =   393217
      ReadOnly        =   -1  'True
      TextRTF         =   $"打字.frx":0502
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim t, t1, r, w, l As Integer
Dim m, s As Integer
Dim ex As String
Dim i As Integer
Dim sysj As Integer
Dim len1 As Integer
Dim len2 As Integer
Dim pos1 As Integer
Dim pos2 As Integer
Dim sd As Integer
Dim strSQL As String

Dim Conn As New ADODB.Connection
Dim Connstr As String
Dim Rec As ADODB.Recordset

Dim Conn1 As New ADODB.Connection
Dim Connstr1 As String
Dim Rec1 As ADODB.Recordset

Private Sub exit1_Click()
If Form2.Caption = "打字测试" Then
    ex = MsgBox("正在测试中,必须先保存记录才能结束,是否结束?", 36)
    tuichu
'    Dim a As Integer
    Connstr = "dbq=" & App.Path & "\pfsj.mdb" & ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)}"
    Conn.Open Connstr
    Set Rec = New ADODB.Recordset
    Rec.Open "select * from kssj where ZH='" & Form1.Text2.Text & "'", Conn, 1, 3
    If sd > Rec.Fields(2) Then  '记录较好的成绩
        strSQL = "Update kssj Set cj1=" & sd & vbTab & "where zh='" & CStr(Form2.xh3.Caption) & "'"
        Conn.Execute (strSQL)
        MsgBox "^-^,有进步!系统将记录你的新成绩。"
    Else
        MsgBox "未超过上次成绩!本次成绩不做记录。"
    End If
     End
Else
    ex = MsgBox("是否退出?", 36)
    If ex = vbYes Then
    tuichu
    Form2.Hide
    End If
End If
End Sub

Private Sub Form_Load()
RichTextBox1(0).Locked = True
time1.Visible = True
time2.Visible = False
settime.Visible = False
r = 0
w = 0
l = 0
zhanting.Caption = "暂停"
'RichTextBox1(0).FileName = App.Path & "\文章\aaa.txt"
t1 = 600
t = t1
m = Int(t / 60)
s = t Mod 60
time1.Caption = m & ";" & s
op.Visible = False
End Sub

Private Sub op_Click()
t = t1
m = Int(t / 60)
s = t Mod 60
time1.Caption = m & ";" & s
Form4.Show
Me.Hide
End Sub

Private Sub RichTextBox1_Change(Index As Integer)
'根据学生打字的正确与否标注不同颜色
    If Index = 1 Then
    Dim d As Integer '被选文本的长度
    Dim ans As VbMsgBoxResult
    len2 = Len(RichTextBox1(1).Text) '新的长度
    pos2 = RichTextBox1(1).SelStart '光标的新位置
        If len2 > len1 Then '内容增加,从光标的初始位置开始比较
            For i = pos1 To len2 - 1
                RichTextBox1(0).SelStart = i
                RichTextBox1(0).SelLength = 1
                If Mid(RichTextBox1(1).Text, i + 1, 1) = Mid(RichTextBox1(0).Text, i + 1, 1) Then
                    RichTextBox1(0).SelColor = RGB(0, 0, 255) '正确(蓝)
                Else
                    RichTextBox1(0).SelColor = RGB(255, 0, 0) '错误(红)
                End If
            Next
        End If
        If len2 < len1 Then '内容减少,从光标的新位置开始比较
            For i = pos2 To len2 - 1
                RichTextBox1(0).SelStart = i
                RichTextBox1(0).SelLength = 1
                If Mid(RichTextBox1(1).Text, i + 1, 1) = Mid(RichTextBox1(0).Text, i + 1, 1) Then
                    RichTextBox1(0).SelColor = RGB(0, 0, 255) '正确(蓝)
                Else
                    RichTextBox1(0).SelColor = RGB(255, 0, 0) '错误(红)
                End If
            Next
            d = len1 - len2 '减少长度,恢复原色
            RichTextBox1(0).SelStart = len2
            RichTextBox1(0).SelLength = d + 1
            RichTextBox1(0).SelColor = RGB(0, 0, 0) '恢复原来颜色(黑)
        End If
    len1 = len2
    pos1 = pos2
    End If
End Sub

Private Sub RichTextBox1_KeyPress(Index As Integer, KeyAscii As Integer)
    If Len(RichTextBox1(1).Text) = Len(RichTextBox1(0).Text) Then KeyAscii = 0
End Sub

Private Sub RichTextBox1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
'If Index = 0 Then RichTextBox1(1).SetFocus
If RichTextBox1(0).SelLength > 0 Then RichTextBox1(0).SelLength = 0
End Sub

Private Sub RichTextBox1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
If RichTextBox1(0).SelLength > 0 Then RichTextBox1(0).SelLength = 0
End Sub

Private Sub settime_Click()
If settime.Value = 1 Then
    time1.Visible = False
    time2.Visible = True
    op.Enabled = False
    exit1.Enabled = False
    zhanting.Enabled = False
    time2.Text = ""
Else
    op.Enabled = True
    exit1.Enabled = True
    zhanting.Enabled = True
    If time2.Text <> "" Then
        Dim z As VbMsgBoxResult
        z = MsgBox("是否使用已改变的时间?", vbQuestion + vbOKCancel)
        If z = vbOK Then
        t1 = Val(time2.Text) * 60
        t = t1
        m = Int(t / 60)
        s = t Mod 60
        time1.Caption = m & ";" & s
        RichTextBox1(1).Text = ""
        End If
    End If
End If
'time2.Text = time1.Caption
End Sub

Private Sub time2_KeyPress(KeyAscii As Integer)
If KeyAscii <> 8 Then
    If KeyAscii < 48 Or KeyAscii > 57 Or Len(time2.Text) > 1 Then KeyAscii = 0
End If
End Sub

Private Sub Timer1_Timer()
'RichTextBox1(1).SetFocus
Select Case t
    Case Is > 0
     t = t - 1
    Case Is = 0
     Timer1.Enabled = False
     MsgBox "时间到"
     l = Len(RichTextBox1(1).Text)
     For i = 0 To l
        RichTextBox1(0).SelStart = i
        RichTextBox1(0).SelLength = 1
        If RichTextBox1(0).SelColor = RGB(0, 0, 255) Then
         r = r + 1
        Else
         w = w + 1
        End If
     Next
     Form3.Show
     l = Len(RichTextBox1(1).Text)
     sysj = t1 - t
     Form3.Label(1).Caption = l
     Form3.Label(2).Caption = w
     Form3.Label(3).Caption = r
     Form3.Label(4).Caption = sysj
     Form3.Label(5).Caption = (l \ sysj) * 60
     Me.Enabled = False
End Select
m = Int(t / 60)
s = t Mod 60
time1.Caption = m & ";" & s
End Sub

Private Sub zhanting_Click()
If zhanting.Caption = "暂停" Then
    zhanting.Caption = "继续"
    Timer1.Enabled = False
    RichTextBox1(1).Enabled = False
    op.Visible = True
    settime.Visible = True
Else
    zhanting.Caption = "暂停"
    Timer1.Enabled = True
    RichTextBox1(1).Enabled = True
    op.Visible = False
    settime.Visible = False
    time2.Visible = False
    time1.Visible = True
    m = Int(t / 60)
    s = t Mod 60
    time1.Caption = m & ";" & s
End If
End Sub
Sub tuichu()
Timer1.Enabled = False
l = Len(RichTextBox1(1).Text)
For i = 0 To l
    RichTextBox1(0).SelStart = i
    RichTextBox1(0).SelLength = 1
    If RichTextBox1(0).SelColor = RGB(0, 0, 255) Then
    r = r + 1
    ElseIf RichTextBox1(0).SelColor = RGB(255, 0, 0) Then
    w = w + 1
    End If
Next
Form3.Show
sysj = t1 - t
Form3.Label(1).Caption = l
Form3.Label(2).Caption = w
Form3.Label(3).Caption = r
Form3.Label(4).Caption = sysj
If sysj = 0 Then
   sd = 0
Else
   sd = (l \ sysj) * 60
End If
Form3.Label(5).Caption = sd
RichTextBox1(1).Locked = True
End Sub

 

⌨️ 快捷键说明

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