写vb程序,转换方法为:〔90,100〕为 A,〔80,89〕为 B,〔70,79〕为 C,〔60,69〕为 D,60以下为 E。

来源:百度知道 编辑:UC知道 时间:2024/05/14 20:07:06

Dim a As Integer
a = Text1.Text
If a < 0 Or a > 100 Then
MsgBox "请输入100以内的数"
Exit Sub
End If
Dim b As String
Select Case a \ 10
Case 0 To 5
b = "E"
Case 6
b = "D"
Case 7
b = "C"
Case 8
b = "B"
Case 9 To 10
b = "A"
End Select

MsgBox b

假设待转换的数为text1输入,单击command1按钮开始转换,转换结果放在text2中。代码如下:
Private Sub Command1_Click()
Dim x as Single
x=Val(Text1) '若不是由text1输入,请改这里
Selcet Case x
Case Is>=90 And Is<=100:Text2="A"
Case Is>=80 And Is<90:Text2="B"
Case Is>=70 And Is<80:Text2="C"
Case Is>=60 And Is<70:Text2="D"
Case Else:Text2="E"
End Select