当前位置: 网学 > 编程文档 > VB > 正文

用VB6.0设计一个打字练习软件

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式

  If LenB(Text1(Index).Text) = LenB(Label1(Index).Caption) Then
   If Index = rowcount Then
    Timer1.Enabled = False
    mode = ""
    Dim i, j, rightchar As Integer
    rightchar = 0
    ''统计每一行打字的正确字数
    For i = 1 To rowcount
     For j = 1 To Len(Label1(i).Caption)
      If Mid(Text1(i).Text, j, 1) = Mid(Label1(i).Caption, j, 1) Then rightchar = rightchar + 1
     Next
    Next
  If MsgBox("finish task!Correct Percent:" & Int((rightchar / totalchar) * 100) & "%" + vbCrLf + vbCrLf + "Do you want to save this practice result?", vbYesNo + vbInformation, "Hint") = vbYes Then
''将打字速度结果存入文本文件中
  Open App.Path + "\count.txt" For Append As #1
  If playsec = 0 Then
   Print #1, 0
  Else
   Print #1, CStr(totalchar / playsec)
  End If
  Close #1
End If
 ''计时清0
  playsec = 0
 Else
 Index = Index + 1
 Text1(Index).SetFocus
 End If
 End If
End Sub
''------------------------------------------
Private Sub Text1_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
 ''在打字输入框中屏蔽掉方向键和删除键等,以避免玩家误操作
 If KeyCode = vbKeyLeft Then KeyCode = 0
 If KeyCode = vbKeyRight Then KeyCode = 0
 If KeyCode = vbKeyUp Then KeyCode = 0
 If KeyCode = vbKeyDown Then KeyCode = 0
 If KeyCode = vbKeyDelete Then KeyCode = 0
 If KeyCode = vbKeyHome Then KeyCode = 0
 If KeyCode = vbKeyEnd Then KeyCode = 0
End Sub
''-------------------------------------------
Private Sub Text1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
 ''如果用鼠标点击输入框,则作为作弊行为,重新开始练习
 MsgBox "Don''t cheat youself,Please studying carefully!" + vbCrLf + vbCrLf + "[Suggestion : This Way is to advantage you]", vbOKOnly + vbInformation, "Warning"
 Call mnuRestart_Click
End Sub
''-------------------------------------------
Private Sub Timer1_Timer()
 ''计算当前练习所耗时间,以秒为单位
 playsec = playsec + 1
 StatusBar1.Panels(2).Text = "Seconds Used : " & playsec & "(S)"
End Sub

  至此,你就拥有了一个属于自己的打字小软件了。按F5运行它,效果还不错吧,有兴趣的朋友还可以加上一些特殊功能,比如背景音乐,字体颜色或者游戏功能。  

  (备注:本程序在VB6.0+WIN2000下调试通过)

  • 下一篇资讯: MASM-打字练习程序
  • 网学推荐

    免费论文

    原创论文

    浏览:
    设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
    版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
    Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
    湘ICP备09003080号