寻VB高手(悬赏积分20)

来源:百度知道 编辑:UC知道 时间:2024/06/20 17:39:02
VB题:二.编一程序输入上网的时间并计算上网费用,计算的方法如下:

费用=基数30元(上网时间<10小时),每小时2.5元(上网时间10-50)小时。每小时2元(上网时间大于等于50小时)

同时为了鼓励多上网,每月收费最多不超过150元

提示:首先利用多分支条件根据三个时间段算出费用,然后再用If语句对超过150元的费用设置为150元。

要求代码完整。

Private Sub Form_Click()
Dim n As Single
Dim y As Single
n = InputBox("请输入上网时间数")

If n < 10 Then
y = 30
ElseIf n < 50 Then
y = n * 2.5
Else
y = n * 2
End If
If y < 150 Then
Print y;
Else
y = 150
Print y;
End If
End Sub

Public Function countfee(usertime As Integer) As Single
Dim tmp As Single
If usertime < 10 Then
tmp = 30
ElseIf usertime < 50 Then
tmp = usertime * 2.5
Else
tmp = usertime * 2
End If
If tmp > 150 Then tmp = 150
countfee = tmp
End Function

Private Sub Form_Click()
Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
Select Case a
Case a < 10
b = 30
Text1.Text = b

Case a >= 10 And a <= 50
Print 2.5 * a
Case a >