Dim Begin_nian0
Set Begin_nian0 = HMIRuntime.Tags("Begin_nian")
Begin_nian0.Read
Dim Begin_yue0
Set Begin_yue0 = HMIRuntime.Tags("Begin_yue")
Begin_yue0.Read
Dim Begin_ri0
Set Begin_ri0 = HMIRuntime.Tags("Begin_ri")
Begin_ri0.Read
Dim Begin_shi0
Set Begin_shi0 = HMIRuntime.Tags("Begin_shi")
Begin_shi0.Read
Dim Begin_fen0
Set Begin_fen0 = HMIRuntime.Tags("Begin_fen")
Begin_fen0.Read
Dim Begin_miao0
Set Begin_miao0 = HMIRuntime.Tags("Begin_miao")
Begin_miao0.Read
建立了6个输入输出域,分别连接年,月,日,时,分,秒,如何将6个数字连接起来赋值给UTCBeginTime?
下面错在哪里,为什么什么也没有?
UTCBeginTime = Year(Begin_nian0) & "-" & Month(Begin_yue0) & "-" & Day(Begin_ri0) & " " & Hour(Begin_shi0-8) & ":" & Minute(Begin_fen0) & ":" & Second(Begin_miao0)
MsgBox UTCBeginTime
最佳答案
你定义的这些变量实际是对象变量而不是字符串变量,取得值要用对象的Value属性
UTCBeginTime = Year(Begin_nian0.Value) & "-" & Month(Begin_yue0.Value) & "-" & Day(Begin_ri0.Value) & " " & Hour(Begin_shi0.Value) & ":" & Minute(Begin_fen0.Value) & ":" & Second(Begin_miao0.Value)
另外小时直接减8当实际小时小于8时就是负值了,可以用DateAdd函数
Msgbox DateAdd("h",-8,UTCBeginTime)
提问者对于答案的评价:
谢谢了
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc255969.html