• vb.net 打字练习


    Public Class Form1
        Dim t As Date
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim inputdata As String
            OpenFileDialog1.FileName = "*txt"
            OpenFileDialog1.InitialDirectory = "C:/Documents and Settings/Administrator/桌面/指法练习/指法练习/bin/Debug"
            OpenFileDialog1.Filter = "text files(*.txt)|*.txt|all iles(*.*)|*.*"
            OpenFileDialog1.FilterIndex = 2
            OpenFileDialog1.ShowDialog()
            FileOpen(1, OpenFileDialog1.FileName, OpenMode.Input)
            RichTextBox1.Text = ""
            Do While Not EOF(1)
                inputdata = LineInput(1)
                RichTextBox1.Text = RichTextBox1.Text + inputdata + vbCrLf
            Loop
            FileClose(1)
        End Sub

       
        Private Sub RichTextBox2_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox2.GotFocus
            t = TimeOfDay
        End Sub

        Private Sub RichTextBox2_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles RichTextBox2.KeyDown
            Dim l As Integer
            l = RichTextBox2.TextLength
            Dim t2, n, y, i As Integer
            If e.KeyCode = Keys.Enter Then
                t2 = DateDiff("s", t, TimeOfDay)
                TextBox1.Text = t2 & "秒"
                RichTextBox2.ReadOnly = True
                y = 0 : n = 0
                For i = 1 To l
                    If Mid(RichTextBox1.Text, i, 1) = Mid(RichTextBox2.Text, i, 1) Then
                        y = y + 1
                    Else
                        n = n + 1
                    End If
                Next i
                y = y / l * 100
                TextBox2.Text = Format(y, "0.00") & "%"

            End If
        End Sub
        Private Sub RichTextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles RichTextBox2.KeyPress
            Dim t2, n, y, i As Integer
            If RichTextBox2.TextLength + 1 = RichTextBox1.TextLength Then
                t2 = DateDiff("s", t, TimeOfDay)
                TextBox1.Text = t2 & "秒"
                RichTextBox2.ReadOnly = True
                y = 0 : n = 0
                For i = 1 To 4
                    If Mid(RichTextBox1.Text, i, 1) = Mid(RichTextBox2.Text, i, 1) Then
                        y = y + 1
                    Else
                        n = n + 1
                    End If
                Next i
                y = y / 4 * 100
                TextBox2.Text = Format(y, "0.00") & "%"
            End If
        End Sub

    End Class

  • 相关阅读:
    38.Linux驱动调试-根据系统时钟定位出错位置
    37.Linux驱动调试-根据oops的栈信息,确定函数调用过程
    36.Linux驱动调试-根据oops定位错误代码行
    35.Linux-分析并制作环形缓冲区
    34.Linux-printk分析、使用__FILE__, __FUNCTION__, __LINE__ 调试
    arm裸板驱动总结(makefile+lds链接脚本+裸板调试)
    33.Linux-实现U盘自动挂载(详解)
    Android插件化技术——原理篇
    Android插件化(五):OpenAtlasの四大组件的Hack
    Android插件化(4):OpenAtlasの插件的卸载与更新
  • 原文地址:https://www.cnblogs.com/hgmyz/p/12352945.html
Copyright © 2020-2023  润新知