求问一道VB题目谢谢
11、下列程序是在文本框中输入成绩,按回车后,根据成绩显示星级;如果输入非数字,也给出提示,但不计算星级。PrivateSubTextBox1_KeyPress(……)H...
11、下列程序是在文本框中输入成绩,按回车后,根据成绩显示星级;如果输入非数字,也给出提示,但不计算星级。
Private Sub TextBox1_KeyPress(……) Handles TextBox1.KeyPress
Dim m As Integer
If (1) = 13 Then
If (2) Then
Label1.Text = "不是数字,不能评星级"
Exit Sub
End If
m = Val(TextBox1.Text)
Select Case m
Case 90 To 100
Label1.Text = m & "分3星"
Case 75 To 89
Label1.Text = m & "分2星"
Case 60 To 74
Label1.Text = m & "分1星"
Case (3)
Label1.Text = m & "分0星"
End Select
End If
End Sub
1 2 3个空各填什么谢谢 展开
Private Sub TextBox1_KeyPress(……) Handles TextBox1.KeyPress
Dim m As Integer
If (1) = 13 Then
If (2) Then
Label1.Text = "不是数字,不能评星级"
Exit Sub
End If
m = Val(TextBox1.Text)
Select Case m
Case 90 To 100
Label1.Text = m & "分3星"
Case 75 To 89
Label1.Text = m & "分2星"
Case 60 To 74
Label1.Text = m & "分1星"
Case (3)
Label1.Text = m & "分0星"
End Select
End If
End Sub
1 2 3个空各填什么谢谢 展开
1个回答
展开全部
Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
Dim m As Integer
If Asc(e.KeyChar) = 13 Then
If IsNumeric(TextBox1.Text) Then
Label1.Text = "不是数字,不能评星级"
Exit Sub
End If
m = Val(TextBox1.Text)
Select Case m
Case 90 To 100
Label1.Text = m & "分3星"
Case 75 To 89
Label1.Text = m & "分2星"
Case 60 To 74
Label1.Text = m & "分1星"
Case Else
Label1.Text = m & "分0星"
End Select
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询