在wincc中用mircosoftdateandtimepicker控件怎么把控件的值读到变量中,格式为(2016-4-2)
最佳答案
设置四个变量STaRTDate,StartDate-1,StopDate,StopDate-1对应控件DTPicker_1,DTPicker_2,DTPicker_3,DTPicker_4。为开始查询的日期和时间,结束的日期和时间。
SubValue_OnPropertyChanged(ByValItem,ByValvalue)
DimfromData,fromtime,toData,toTime,startDT,stopDT
Dimdata1,data2,data3,data4
DimStartData
SetStartData=HMIRuntime.Tags("StartDate")
DimStopData
SetStopData=HMIRuntime.Tags("StopDate")
StartData.Read
StopData.Read
DimStartData_1
SetStartData_1=HMIRuntime.Tags("StartDate_1")
DimStopData_1
SetStopData_1=HMIRuntime.Tags("StopDate_1")
StartData_1.Read
StopData_1.Read
SetfromData=ScreenItems("DTPicker_1")
Setfromtime=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
SettoData=ScreenItems("DTPicker_3")
SettoTime=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
”MsgBoxStartData.Value
”MsgBoxStopData.Value
EndSub
图片说明:
c39ec1670502bc2FC1108accc3669f7e
提问者对于答案的评价:
谢谢