dim rec as new adodb.recordset
con.connectionstring="省略"
con.open
rec.cursorlocation = aduseclient
private sub command1_click()'充值
rec.open "select * from memory where memory.id ='" &text1.text &"'" ,con,adopenkeyset ,adlockoptimistic
if rec.recordcount =0 then '如果没有此编号
rec.addnew
rec.field(0)= text1.text
rec.field(1) = val(trim(text2.text))
rec.update
else
rec.field(1) = rec.field(1)+val(trim(text2.text))
rec.update
end if
rec.close
end sub
private sub command2_click()'扣款
rec.open "select * from memory where memory.id ='" &text1.text &"'" ,con,adopenkeyset ,adlockoptimistic
if rec.recordcount =0 then '如果没拍大有此iD
msgbox "无法完成扣款"
else
if rec.field(1) <val(trim(text2.text)) then
msgbox "余额不足,无法完成扣款"裤亩
else
rec.field(1) = field(1) - val(trim(text2.text))
rec.update
end if
end if
rec.close
end sub
虽然很可能帮不上忙袭纯竖,还是写了几句。
用timer控凳蚂卜件设定时间间隔1s,timer事件中,timer.enable=true,物冲time=time+1,time全局变量停止计费按钮中
timer.enable=flase
if time<=180 then
if time mod 60=0 then
total=0.2*fix(time/60)
else
total=0.2*(fix(time/60)+1)
end if
else
if time mod 60=0 then
total=0.6+0.1*(fix(time/60)-3)
else
total=0.6+0.1*(fix(time/60)-2)
end if
end if
其他枣穗你自己添吧
字体大小胡宏自己设置和咐:
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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)