Sub OnClick(ByVal Item)
Dim i
Dim plt_thk,plt_wid,plt_len,pdi_tar_thk,pdi_tar_wid
Dim stl_code,pdi_tar_len
Dim mystr,mystr1
Dim Msg
Dim shear_len,shear_amount,shear_len2,shear_amount2
Dim mydate,myorder,myclass
Dim inputtime,myuser,prod_status
Dim d_num
myorder=HMIRuntime.Tags("D_order").Read
If myorder=0 Then
Msg=MsgBox("Data not complete",16,"Input Information")
Exit Sub
End If
mydate=HMIRuntime.Tags("D_plan_date").Read
If mydate="" Then
Msg=MsgBox("Please input plan date!",16,"Input Information")
Exit Sub
End If
plt_thk=HMIRuntime.Tags("D_plt_thk").Read
plt_wid=HMIRuntime.Tags("D_plt_wid").Read
plt_len=HMIRuntime.Tags("D_plt_len").Read
pdi_tar_thk=HMIRuntime.Tags("D_tar_thk").Read
pdi_tar_wid=HMIRuntime.Tags("D_tar_wid").Read
stl_code=Trim(HMIRuntime.Tags("D_steel_grade").Read)
shear_len=HMIRuntime.Tags("D_shear_len").Read
shear_amount=HMIRuntime.Tags("D_shear_amount").Read
shear_len2=HMIRuntime.Tags("D_shear_len_2").Read
shear_amount2=HMIRuntime.Tags("D_shear_amount_2").Read
prod_status=HMIRuntime.Tags("D_prod_status").Read
inputtime=Now
myclass=HMIRuntime.Tags("D_class").Read
myuser=HMIRuntime.Tags("@CurrentUser").Read
d_num=HMIRuntime.Tags("D_amount").Read
If pdi_tar_thk=0 Or pdi_tar_wid=0 Then
Msg=MsgBox("data inputing not complete",16,"Input Information")
Exit Sub
End If
mystr1="(" & myorder & ",'" & Trim(stl_code) & "'," & plt_thk & "," & plt_wid & "," & plt_len & "," & pdi_tar_thk & "," & pdi_tar_wid & ","_
& shear_len & "," & shear_amount & "," & prod_status & "," & shear_len2 & "," & shear_amount2 & ",'" & inputtime &"','" & mydate & "','" & myuser &"'," & myclass &","& d_num &")"
mystr="INSERT INTO D_plan_data VALUES" & mystr1
HMIRuntime.Trace "mystr=" & mystr & vbCrLf
Datamanage(mystr)
If err.number=0 Then
msg=MsgBox("Save OK! ",0,"Dispatcher Plan")
Else
msg=MsgBox(" Save failure! ",0,"Dispatcher Plan")
End If
End Sub
问题补充:
能具体注明下各段程序的含义嘛?
我以前没学过VB~!~!
最佳答案
这是插入数据到数据库中.是WINCC与数据之间的一段代码
提问者对于答案的评价:
恩 是这样的
原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc274548.html