菩提无悔 2013-09-09 07:56 采纳率: 60%
浏览 2773
已采纳

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

  • 写回答

1条回答 默认 最新

  • ProgPerson 2013-12-05 10:49
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单纯型python实现编译报错
  • ¥15 c++2013读写oracle
  • ¥15 c++ gmssl sm2验签demo
  • ¥15 关于模的完全剩余系(关键词-数学方法)
  • ¥15 有没有人懂这个博图程序怎么写,还要跟SFB连接,真的不会,求帮助
  • ¥15 PVE8.2.7无法成功使用a5000的vGPU,什么原因
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音
  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题