haihongyuan.com
海量文库 文档专家
全站搜索:
您现在的位置:首页 > 初中教育 > 初中作文初中作文

vbs

发布时间:2014-01-13 12:52:53  

Dim obj_sock1,obj_sock2
Set obj_sock2=HMIRuntime.Screens("pmain").ScreenItems("objsock2")
obj_sock2.Protocol="sckUDPProtocol"
obj_sock2.LocalPort=6005
obj_sock2.RemoteHost="192.168.1.103"
obj_sock2.Bind

Set obj_sock1=HMIRuntime.Screens("pmain").ScreenItems("objsock1")
obj_sock1.RemoteHost="192.168.1.103"
obj_sock1.RemotePort=6000
obj_sock1.Connect





Set Obj_SockClient = ScreenItems("objsock")
Set cnvt = CreateObject("ADs.ArrayConvert")
item.GetData strReceive
strFromRec = ""
For i = 0 To 9
UBound(strReceive)
'将接收到的BYTE()型数据转换为String型数据
strFromRec = strFromRec & Right("0" & Hex(AscB(MidB(strReceive , i + 1 ,1))) , 2 )
Next

'解析出80个模拟量并赋值给相应的变量
Set Tag_f = HMIRuntime.Tags("rel")
'此处使用了DLL中的数据转换函数,CvHexStr2vReal2的功能是将十六进制字符串表示的单精度浮点数转换成实际的浮点数值。该函数后面还要讲到。
Tag_f.Value = cnvt.CvHexStr2vReal2(Mid(strFromRec,0,8))
Tag_f.Write,1
Set Tag_b = HMIRuntime.Tags("bol")
Tag_b.Value = True
Tag_b.Write










Dim Tag_i,Tag_o,tag_r,tag_b

Set Tag_i = HMIRuntime.Tags("com_in")
Tag_i.Value = 0
Tag_i.Write
Set Tag_o = HMIRuntime.Tags("com_out")
Tag_o.Value = 0
Tag_o.Write
Set tag_r = HMIRuntime.Tags("rel")
tag_r.Value = 0
tag_r.Write
Set tag_b = HMIRuntime.Tags("bol")
tag_b.Value = 0
tag_b.Write







Dim Tag_i,Tag_o,tag_r,tag_b


Set Tag_i = HMIRuntime.Tags("com_in")
Tag_i.Value = 67
Tag_i.Write
Set Tag_o = HMIRuntime.Tags("com_out")
Tag_o.Value = 25
Tag_o.Write
Set tag_r = HMIRuntime.Tags("rel")
tag_r.Value = 25.1
tag_r.Write
Set tag_b = HMIRuntime.Tags("bol")
tag_b.Value = True
tag_b.Write








Dim objExcelApp,objExcelBook,objExcelSheet
Dim tagwendu,tagyali,tagliuliang,tagyuanliao,tagchengfen
Dim tagshijian,sheetname,username,zhushi
Dim x,y,z,i,j
Dim msg


set tagwendu=HMIRuntime.Tags("rel")
set tagyali=HMIRuntime.Tags("rel1")
set tagliuliang=HMIRuntime.Tags("rel2")
set tagyuanliao=HMIRuntime.Tags("rel3")


msg="ok"
sheetname="sheetdemo"
On Error Resume Next
Dim ExcelApp,ExcelBook
Set ExcelApp=GetObject(,"Excel.Application")
if TypeName(ExcelApp)="Application" Then
For Each ExcelBook In ExcelApp.WorkBooks
if ExcelBook.FullName="E:\work\text.xls" Then
ExcelApp.ActiveWorkbook.Save
ExcelApp.Workbooks.Close
ExcelApp.Quit
Set ExcelApp=Nothing
Exit For
End if
Next
End if
Set objExcelApp=CreateObject("Excel.Application")
objExcelApp.Visible=True
objExcelApp.Workbooks.Open"E:\work\text.xls"
objExcelApp.Worksheets(sheetname).Activate
With objExcelApp.Worksheets(sheetname)
For i=5 To 25
For j=1 To 7
.cells(i,j)=Null
Next
Next
For i=26 To 26
For j=1 To 6
.cells(i,j)=Null
Next
Next
End With
tagshijian=NOW
objExcelApp.Worksheets(sheetname).cells(2,2).value=tagshijian
username.Read
objExcelApp.Worksheets(sheetname).cells(2,7).value=username.Value
zhushi.Read
objE

xcelApp.Worksheets(sheetname).cells(27,7).value=zhushi.Value
objExcelApp.Worksheets(sheetname).cells(27,7).Font.Bold=TRUE
objExcelApp.Worksheets(sheetname).cells(27,7).Interior.ClorIndex=25
objExcelApp.Worksheets(sheetname).cells(27,7).Font.ColorIndex=7
objExcelApp.Worksheets(sheetname).cells(27,7).Font.size=18

With objExcelApp.Worksheets(sheetname)
.cells(5,1).value=tagshijian
tagwendu.Read
.cells(5,2).value=tagwendu.Value
tagyali.Read
.cells(5,3).value=tagyali.Value
tagyuanliao.Read
.cells(5,4).value=tagyuanliao.Value
tagliuliang.Read
.cells(5,5).value=tagliuliang.Value

End With
MsgBox msg

Dim patch,filename
filename=CStr(Year(NOW))&CStr(Month(NOW))&CStr(Day(NOW))&CStr(Hour(NOW))+CStr(Minute(NOW))&CStr(Second(NOW))
patch="d:\"&filename&"demo.xls"
objExcelApp.ActiveWorkbook.SaveAs patch
objExcelApp.Workbooks.Close
objExcelApp.Quit
Set objExcelApp=Nothing

网站首页网站地图 站长统计
All rights reserved Powered by 海文库
copyright ©right 2010-2011。
文档资料库内容来自网络,如有侵犯请联系客服。zhit326@126.com