编写一个vb公用电话计时收费程序?

编写一个vb公用电话计时收费程序?,第1张

字体大小自己设置:

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

如果是帖子文字这样所有的IF都是判断一个变量,使用SELECT CASE文件是完美解决方案,在最后的CASE ELSE里面MSGBOX "全部都不满足"

图片真没办法看清楚,好像和帖子文本的不同,不是所有IF都判断一个变量,那还只有用IF判断,最后要检测所有的IF都没有满足,需要增加一个变量,按照帖子代码的框架这么写:

dim passed as boolean '定义变量

passed = false'初始化

if t1.text =xx then

t2.text=号码1

t3.text=号码2

passed = true '设置标记

end if

if t1.text =yy then

t2.text=号码3

t3.text=号码4

passed = true '设置标记

end if

'最后判断

if not passed then msgbox "全部都不满足"


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存