用VB如何设计打字程序啊,各位大哥大姐帮帮忙啊。

用VB如何设计打字程序啊,各位大哥大姐帮帮忙啊。,第1张

添加控件.

command1 frame1 (label1……label6 timer1 timer2)

'窗体代码,测试好的,大概就是这样 稍微改下就可以实现你所说的功能

Option Explicit

Dim score As Integer

Dim speed As Integer

Sub init()

Label1.Caption = Chr(Int(Rnd * 26) + 49) ' / 设定Label1随机显示的字母

speed = Int(Rnd * 100 + 100) '/ 设定Label1随机显示字母的速度

Label1.Left = Int(Rnd * Frame1.Width) '/ 设定Label1代表字母出现的左边位置

Label1.Top = Frame1.Top '/ 设定Label1代表字母出现的顶部位置

End Sub

Sub init1()

Label6.Caption = Chr(Int(Rnd * 26) + 97) '/ 设定Label2随机显示的字母

speed = Int(Rnd * 100 + 100) '/ 设定Label2随机显示字母的速度

Label6.Left = Int(Rnd * Frame1.Width) ' / 设定Label2代表字母出现的左边位置

Label6.Top = Frame1.Top ' / 设定Label2代表字母出现的顶部位置

End Sub

Private Sub Command1_Click()

init ' /调用init子程序

Timer1.Enabled = True '/ 激活Time1控件

Timer2.Enabled = True '/ 激活Time2控件

Command1.Visible = False

Label5.Caption = 200

Label4.Caption = 0

End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)

If Chr(KeyAscii) = Label1.Caption Then ' /校验键盘输入字符和Label1显示的字符

init

score = score + 1 ' / 得链纳败分加1

Label4.Caption = score

End If

If Chr(KeyAscii) = Label6.Caption Then ' /校验键盘输入字符和Label2显示的字符

init1

score = score + 1

Label4.Caption = score '/ Label4控件显示得分情况

End If

End Sub

Private Sub Form_Load()

Randomize

Timer1.Enabled = False '/ Time1控件失效

Timer2.Enabled = False '/ Time2控件失效

End Sub

Private Sub Timer1_Timer()

Label1.Top = Label1.Top + speed

If Label1.Top >Frame1.Height Then ' /第一个字母超出屏幕范围的时候调用init子程棚颤序重新出现一个字母

init

End If

Label6.Top = Label6.Top + speed

If Label6.Top >Frame1.Height Then'/第二个字母超出屏幕范围的时候调用init1子程序重新出现一个字母

init1

End If

End Sub

Private Sub Timer2_Timer()

Label5.Caption = Val(Label5.Caption) - 1 '/ 扣除剩余个数中的一个

If Val(Label5.Caption) <= 0 Then

Timer1.Enabled = False '/ 剩余个数小于等于0的时候结束练习

Label1.Caption = "" ' / 不显示字母

Label6.Caption = ""

Select Case score

Case Is <= 80

MsgBox vbCrLf + "别放弃,再来一次!" '/ 显示信息框

Case Is <120

MsgBox vbCrLf + "成绩不错,加油!"

Case Is <150

MsgBox vbCrLf + "再努力做的更好一茄并些!"

Case Is >180

MsgBox vbCrLf + "好厉害!最高分呀!"

End Select

Command1.Visible = True

Label4.Caption = 0

Label5.Caption = 200

Timer1.Enabled = False

Timer2.Enabled = False

End If

End Sub

不知道这个合不合你意 哈哈#include<stdio.h>

#include<time.h>肢橡

#include<stdlib.h>int main()

{

int i,j,count1=0,count2=0,c=1

char ch[100],data[100]

srand(time(NULL))

for(i=0i<100i++)

{

j = rand()%52 + 0

if(j<26)

{

c = 2

ch[i] = j + 'A'

}

else

ch[i] = j + 'A' + 6

}

if(c == 1)

{

printf("等级为1\n")

for(i=0i<100i++)

printf("%c",ch[i])

}

else

{

printf("等级为2\敬差n")

for(i=0i<100i++)

printf("%c",ch[i])

}

printf("\n")

for(i =0i<100i++)

{

scanf("%c",&data[i])

}

for(i=0i<100i++)

{

if(data[i] == ch[i])

{

printf("%c",data[i])

count1++

}

else

{

printf("*")

count2++

}

}

printf("\n")

printf("对了亮饥皮%d个\n",count1)

printf("错了%d个\n",count2)

return 1

}数字可以自己改的!


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/12558171.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2025-08-26
下一篇2025-08-26

发表评论

登录后才能评论

评论列表(0条)

    保存