VB 编写一个出租车计费程序

VB 编写一个出租车计费程序,第1张

text1是KM 公里text2是money 金额 代码如下

Dim km As Long

Dim money As Long

km = Val(Text1)

Select Case km

Case Is <= 3

money = 10 '3公里内10元

Case Is >3 And km <槐租= 20

money = (km - 3) * 2.1 + 10 '3公里外2.1元者明旦每公里 加上3公里内的10元

Case Is >20

money = (km - 3) * 2.1 + (km - 3) + 10 '在第二条基础上,超3公首扰里每公里加1元

End Select

Text2 = money

字体大小胡宏自己设置和咐:

Private Sub Command1_Click()

Command1.Enabled = False

Command2.Enabled = True

Text1 = Right(Now(), 8)

End Sub

Private Sub Command2_Click()

Command2.Enabled = False

Command1.Enabled = True

Text2 = Right(Now(), 8)

h1 = CInt(Left(Text1, 2))

m1 = CInt(Mid(Text1, 4, 2))

s1 = CInt(Right(Text1, 2))

h2 = CInt(Left(Text2, 2))

m2 = CInt(Mid(Text2, 4, 2))

s2 = CInt(Right(Text2, 2))

t = 60 * (h2 - h1) + m2 - m1 + (s2 - s1) / 60

If t <= 3 Then

  y = 0.5

Else

  y = 0.5 + 0.15 * Int(t - 3 + 0.999)

End If

Text3 = y

If Left(Text3, 1) = "." Then Text3 = "0" &Text3

End Sub

Private Sub Form_Load()

Label1.Caption = "开始时间"

Label2.Caption = "结束时间"

Label3.Caption = "通话费用"

Text1 = ""

Text2 = ""唤做纯

Text3 = ""

Command1.Caption = "通话开始"

Command2.Enabled = False

Command2.Caption = "通话结束"

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12275077.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-24
下一篇 2023-05-24

发表评论

登录后才能评论

评论列表(0条)

保存