在WINCC中用mircosoft date and time picker控件 怎么把控件的值读到变量中,格式为(2016-4-2)
最佳答案
设置四个变量StartDate,StartDate-1,StopDate,StopDate-1对应控件DTPicker_1,DTPicker_2,DTPicker_3,DTPicker_4。为开始查询的日期和时间,结束的日期和时间。
Sub Value_OnPropertyChanged(ByVal Item, ByVal value)
Dim fromData,fromtime, toData,toTime,startDT,stopDT
Dim data1,data2,data3,data4
Dim StartData
Set StartData = HMIRuntime.Tags("StartDate")
Dim StopData
Set StopData = HMIRuntime.Tags("StopDate")
StartData.Read
StopData.Read
Dim StartData_1
Set StartData_1 = HMIRuntime.Tags("StartDate_1")
Dim StopData_1
Set StopData_1 = HMIRuntime.Tags("StopDate_1")
StartData_1.Read
StopData_1.Read
Set fromData = ScreenItems("DTPicker_1")
Set fromtime = ScreenItems("DTPicker_2")
data1 = Mid(CStr(fromData.value),1,10)
data2 = Mid(CStr(fromtime.value),12,8)
StartData.Value = data1 + " " + data2
StartData.Write
StartData_1.Value = data1 + " " + data2
StartData_1.Write
Set toData = ScreenItems("DTPicker_3")
Set toTime = ScreenItems("DTPicker_4")
data3 = Mid(CStr(toData.value),1,10)
data4 = Mid(CStr(toTime.value),12,8)
StopData.Value = data3 + " " + data4
StopData.Write
StopData_1.Value = data3 + " " + data4
StopData_1.Write
''MsgBox StartData.Value
''MsgBox StopData.Value
End Sub
图片说明:
提问者对于答案的评价:
谢谢
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc180684.html