
VB:设计如图的VB程序,实现公用电话收费功能。代码直接写在下面,谢啦 60
展开全部
'=========================================================================
'以下代码纯手工打的,可能有问题,也不知道你具体要求,你可以参考一下。
'========================================================================
Dim HH as Integer
Dim MM as Integer
Dim SS as Integer
Dim h as integer
dim m as integer
dim s as integer
'''''开始通话
Sub Command1_Click()
dim tmp as string
tmp = Format(Now,"hh:mm:ss")
Text1.Text = tmp
HH = Var(Left(tmp,2))
SS = Var(Right(tmp,2))
MM= Var(Mid(tmp,4,2))
End Sub
''''结束通话
Sub Command2_Click()
dim tmp as string
Dim tm as double
tmp = Format(Now,"hh:mm:ss")
Text2.Text = tmp
h = Var(Left(tmp,2))
h= Var(Right(tmp,2))
m= Var(Mid(tmp,4,2))
tm = 60*(h-HH)+(m-MM+(s-SS)/60
Text3.Text = Cstr(tm)+"分钟"
End Sb
'''计费
Sub Command3_Click()
dim count as double
dim tm as double
tm = 60*(h-HH)+(m-MM+(s-SS)/60
if(tm<3) Then
Count = 0.5
Else
count = 0.5+0.15*(tm-1)
End If
If HH >= 7 Or HH <=19 Then
Text4.Text = Cstr(count) +"元"
Else
count = count/2
Text4.Text = Cstr(count)+"元"
End if
End Sub
'''清除
Sub Command4_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
'以下代码纯手工打的,可能有问题,也不知道你具体要求,你可以参考一下。
'========================================================================
Dim HH as Integer
Dim MM as Integer
Dim SS as Integer
Dim h as integer
dim m as integer
dim s as integer
'''''开始通话
Sub Command1_Click()
dim tmp as string
tmp = Format(Now,"hh:mm:ss")
Text1.Text = tmp
HH = Var(Left(tmp,2))
SS = Var(Right(tmp,2))
MM= Var(Mid(tmp,4,2))
End Sub
''''结束通话
Sub Command2_Click()
dim tmp as string
Dim tm as double
tmp = Format(Now,"hh:mm:ss")
Text2.Text = tmp
h = Var(Left(tmp,2))
h= Var(Right(tmp,2))
m= Var(Mid(tmp,4,2))
tm = 60*(h-HH)+(m-MM+(s-SS)/60
Text3.Text = Cstr(tm)+"分钟"
End Sb
'''计费
Sub Command3_Click()
dim count as double
dim tm as double
tm = 60*(h-HH)+(m-MM+(s-SS)/60
if(tm<3) Then
Count = 0.5
Else
count = 0.5+0.15*(tm-1)
End If
If HH >= 7 Or HH <=19 Then
Text4.Text = Cstr(count) +"元"
Else
count = count/2
Text4.Text = Cstr(count)+"元"
End if
End Sub
'''清除
Sub Command4_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
End Sub
追问
漏了 一个 timer控件哦,再帮一下忙加上去吧,还有结束通话时的 通话时间怎么在text3上显示
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |