程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> vb與s7 300通訊-VB與西門子s7-300通訊,提示w95_s7.dll未找到

vb與s7 300通訊-VB與西門子s7-300通訊,提示w95_s7.dll未找到

編輯:編程綜合問答
VB與西門子s7-300通訊,提示w95_s7.dll未找到

Option Explicit
Public Declare Function load_tool Lib "w95_s7.dll" (ByVal nr As Byte, ByVal dev As String, adr As PlcAdrType) As Long
Public Declare Function db_read Lib "w95_s7.dll" (ByVal blockno As Long, ByVal no As Long, Amount As Long, value As Byte) As Long
Public Declare Function db_write Lib "w95_s7.dll" (ByVal blockno As Long, ByVal no As Long, Amount As Long, value As Byte) As Long

Type PlcAdrType
ADDRESS As Byte
SEGMENTID As Byte
SLOTNO As Byte
PACKNO As Byte
End Type

在窗口頁面,我建了按鈕,按鈕下代碼如下:
Dim i As Long
Dim a11 As PlcAdrType
a11.ADDRESS = 2
a11.SEGMENTID = 0
a11.SLOTNO = 2
a11.PACKNO = 0
i = load_tool(1, "S7ONLINE", a11)
If (i <> 0) Then
MsgBox ("連接成功")
Else
MsgBox ("連接失敗")
End If

運行程序後,點擊按鈕就會提示我,w95_s7.dll文件未找到,請問列為大神,到底哪裡出了問題?

最佳回答:


不行的,%logpath%不能包在括號裡,應該這樣
Shell "cmd /k mkdir “+LOGPATH+” > nul 2>&1", vbNormalNoFocus
vb調用dos是直接運行引號內的,而不給某一變量賦值。另外包在百分號內的是bat變量而不是vb的變量

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved