![]() |
#2
wp2319572013-03-28 15:23
|

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim time, money As Double
time = Val(TextBox1.Text)
If time <= 2 Then
money = 2
ElseIf time <= 5 Then
If time - Val(time) <> 0 Then
time = Val(time) + 1
money = (time - 2) * 0.5 + 2
Else
money = (time - 2) * 0.5 + 2
End If
Else
MsgBox("您的时间输入有误,请重新输入")
End If
TextBox2.Text = Format(money, "#.00")
End Sub
我就是 想用VB做个 简易的计算路程问题Dim time, money As Double
time = Val(TextBox1.Text)
If time <= 2 Then
money = 2
ElseIf time <= 5 Then
If time - Val(time) <> 0 Then
time = Val(time) + 1
money = (time - 2) * 0.5 + 2
Else
money = (time - 2) * 0.5 + 2
End If
Else
MsgBox("您的时间输入有误,请重新输入")
End If
TextBox2.Text = Format(money, "#.00")
End Sub
2小时以内,做出租车所需钱为2元
2~5小时以内,多出来的部分为0.5元每小时,不足1小时按一小时计算
不能停车5小时以上
我点计算3.1小时 结果他出来2.55元~~~
我感觉是这里出了问题If time - Val(time) <> 0 Then
求大神帮助啊,小弟感激不尽