在我的表单中,我有2个组合框和2个文本框,还有1个临时变量
cboProcedure =显示已注册的程序
dDuration =这是临时变量,它将存储过程的持续时间
cboTime =显示当天的时间,除以临时变量的内容(例如,dDuration =" 1:00",cboTime将显示在下拉菜单中,9:00,10:00,11 :00,12:00)
txtEndTime =程序的结束,这是我想要得到的
Text101 =这是显示dDuration实际值的文本框。(从1:00开始)
我试着编写一个代码来总结cboTime.Text(我选择的是什么)+ [Text101] =它应该给我程序的结束时间,但我得到的是" 8:55 AM + 0: 55&#34 ;.这就是我的尝试。
Format(Me.cboTime, "h:nn AM/PM") & "+" & Format([Text101], "h:nn AM/PM")
我不知道这是否是正确计算时间值的方法......这可能吗?
答案 0 :(得分:0)
好的,所以我解决了,我必须做一些额外的事情来告诉程序9:00 AM + 0:55 = 9:55 AM ...这就是我做的: Dim d,e,m,l As Date
d = Format([Text101], "n")
m = Format(Me.txtAppointDate, "Long Date")
l = Format([cboTime], "h:nn")
e = DateAdd("n", d, l)
Me.txtEndTime = Format(e, "h:nn AMPM")
'我需要根据cboProcedure使这个等式得到一个过程持续时间的值,所以我构建了一个选择案例:
Select Case Me.cboProcedure
Case "Haircut"
dDuration = TimeValue([Text101])
d = Format([Text101], "n")
m = Format(Me.txtAppointDate, "Long Date")
l = Format([cboTime], "h:nn")
e = DateAdd("n", d, l)
Me.txtEndTime = Format(e, "h:nn AMPM")
Case "Hair Coloring"
dDuration = TimeValue([Text107])
d = Format([Text107], "n")
m = Format(Me.txtAppointDate, "Long Date")
l = Format([cboTime], "h:nn")
e = DateAdd("n", d, l)
Me.txtEndTime = Format(e, "h:nn AMPM")
Case "Eyebrows Making"
dDuration = TimeValue([Text109])
d = Format([Text109], "n")
m = Format(Me.txtAppointDate, "Long Date")
l = Format([cboTime], "h:nn")
e = DateAdd("n", d, l)
Me.txtEndTime = Format(e, "h:nn AMPM")
Case "Other"
dDuration = TimeValue([Text111])
d = Format([Text111], "n")
m = Format(Me.txtAppointDate, "Long Date")
l = Format([cboTime], "h:nn")
e = DateAdd("n", d, l)
Me.txtEndTime = Format(e, "h:nn AMPM")
End Select
现在根据程序我的持续时间会花费,所以如果程序是" X"然后做这个数学