level 1
lrdeed
楼主
求作业,大部分做完了,排序不会。
题:做打字测验,显示时间正确率,点另一个BUTTON按正确率排序
主要的问题是:怎么获取那个百分率
我的程序如下:
Public Class Form1
Dim i, t, b, d, q As Integer, s, p As String, per As Double
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case i
Case 0
i = 1
Timer1.Enabled = True
Button1.Text = "结束"
Label2.Text = ""
Label1.Visible = True
Label1.Text = "老师我来晚了对不起啊原谅我吧VB好难啊不会做啊拿不到A啊怎么办啊"
TextBox1.Focus()
Case 1
i = 0
Timer1.Enabled = False
Button1.Text = "开始"
Label2.Text = t & "秒"
t = 0
Label1.Visible = False
s = TextBox1.Text
p = Label1.Text
b = Len(s)
q = Len(p)
For d = 1 To b
If Mid(s, d, 1) <> Mid(p, d, 1) Then
Exit For
End If
Next d
per = (d - 1) / q
Label3.Text = Format(per, "####.00%")
End Select
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
t = t + 1
Label2.Text = t & "秒"
If t > 60 Then
t = 0
MsgBox("你好逊
啊这
么久还没结束", 16, "系统异常!!!")
i = 0
Timer1.Enabled = False
Button1.Text = "开始"
Label2.Text = t & "秒"
Label1.Visible = False
s = TextBox1.Text
p = Label1.Text
b = Len(s)
q = Len(p)
For d = 1 To b
If Mid(s, d, 1) <> Mid(p, d, 1) Then
Exit For
End If
Next d
per = (d - 1) / q
Label3.Text = Format(per, "####.00%")
End
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Visible = False
Label2.Text = ""
Button1.Text = "开始"
Label3.Text = ""
Label4.Text = ""
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If Button1.Text = "开始" Then
MsgBox("作弊被发现啦", 1, "哈哈哈")
TextBox1.Text = ""
End If
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
End Class
2011年10月28日 13点10分
1
题:做打字测验,显示时间正确率,点另一个BUTTON按正确率排序
主要的问题是:怎么获取那个百分率
我的程序如下:
Public Class Form1
Dim i, t, b, d, q As Integer, s, p As String, per As Double
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Select Case i
Case 0
i = 1
Timer1.Enabled = True
Button1.Text = "结束"
Label2.Text = ""
Label1.Visible = True
Label1.Text = "老师我来晚了对不起啊原谅我吧VB好难啊不会做啊拿不到A啊怎么办啊"
TextBox1.Focus()
Case 1
i = 0
Timer1.Enabled = False
Button1.Text = "开始"
Label2.Text = t & "秒"
t = 0
Label1.Visible = False
s = TextBox1.Text
p = Label1.Text
b = Len(s)
q = Len(p)
For d = 1 To b
If Mid(s, d, 1) <> Mid(p, d, 1) Then
Exit For
End If
Next d
per = (d - 1) / q
Label3.Text = Format(per, "####.00%")
End Select
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
t = t + 1
Label2.Text = t & "秒"
If t > 60 Then
t = 0
MsgBox("你好逊
啊这
么久还没结束", 16, "系统异常!!!")
i = 0
Timer1.Enabled = False
Button1.Text = "开始"
Label2.Text = t & "秒"
Label1.Visible = False
s = TextBox1.Text
p = Label1.Text
b = Len(s)
q = Len(p)
For d = 1 To b
If Mid(s, d, 1) <> Mid(p, d, 1) Then
Exit For
End If
Next d
per = (d - 1) / q
Label3.Text = Format(per, "####.00%")
End
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Visible = False
Label2.Text = ""
Button1.Text = "开始"
Label3.Text = ""
Label4.Text = ""
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If Button1.Text = "开始" Then
MsgBox("作弊被发现啦", 1, "哈哈哈")
TextBox1.Text = ""
End If
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
End Class