2 u010035762 u010035762 于 2013.09.09 15:56 提问

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文件未找到,请问列为大神,到底哪里出了问题?

3个回答

XIAOHE321
XIAOHE321   2013.12.05 18:49
已采纳

不行的,%logpath%不能包在括号里,应该这样
Shell "cmd /k mkdir “+LOGPATH+” > nul 2>&1", vbNormalNoFocus
vb调用dos是直接运行引号内的,而不给某一变量赋值。另外包在百分号内的是bat变量而不是vb的变量

jinghaoqiang6
jinghaoqiang6   2015.02.18 02:23

不行的,%logpath%不能包在括号里,应该这样
Shell "cmd /k mkdir “+LOGPATH+” > nul 2>&1", vbNormalNoFocus
vb调用dos是直接运行引号内的,而不给某一变量赋值。另外包在百分号内的是bat变量而不是vb的变量

jinghaoqiang6
jinghaoqiang6   2015.02.18 02:23

不行的,%logpath%不能包在括号里,应该这样
Shell "cmd /k mkdir “+LOGPATH+” > nul 2>&1", vbNormalNoFocus
vb调用dos是直接运行引号内的,而不给某一变量赋值。另外包在百分号内的是bat变量而不是vb的变量

Csdn user default icon
上传中...
上传图片
插入图片