请教各位高手谁可以帮我写一个VBS脚本让小弟参考参考?问题如下我在工控机上做一个清零按钮,点此按钮就把当前的日期和时间,机台号以及对应的产量移到数据表里头;再在工控机上输入查询的开始时间和结束时间来查询在这时间段内的历史数据.小弟在此提前谢过!
最佳答案
Option Explicit
Function action
Dim objconnection
Dim strconnectionstring
Dim a
Dim b
Dim c
Dim d
Dim strsql
Dim objcommand
Dim test
test=HMIRuntime.Tags("test").Read
If test=1 Then
strconnectionstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test.mdb;Persist Security Info=False"
a=HMIRuntime.Tags("a").Read
b=HMIRuntime.Tags("b").Read
c=HMIRuntime.Tags("c").Read
d=HMIRuntime.Tags("d").Read
strsql="INSERT INTO test(a,b,c,d) values ("&a&","&b&","&c&","&d&");"
Set oBjconnection=CreateObject("ADODB.Connection")
objconnection.connectionString=strconnectionstring
objconnectIon.Open
Set objCommand=CreateObject("ADODB.COmmand")
With objcommand
.ActiveConnection=objconnection
.CommandTexT=strsql
End With
objcommand.execute
Set objcommand=Nothing
objconnection.Close
Set objconnection=Nothing
test.value=0
test.write
End If
End Function
提问者对于答案的评价:
很好
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc266416.html