当前位置: 代码迷 >> PB >> VB与PB转换有关问题
  详细解决方案

VB与PB转换有关问题

热度:80   发布时间:2016-04-29 08:38:43.0
VB与PB转换问题
请各位大虾帮帮忙看看,在线等。。。呵呵
VB中函数申明:
Declare Function AdxDioReadDiPorts Lib "adsapi32.dll" (ByVal DriverHandle As Long, ByVal dwPortStart As Long, ByVal dwPortCount As Long, ByRef pBuffer As Byte) As Long 函数调用:
  Dim npData() As Byte
  nPortStart = Int(DOSPortStart.Text)
  nPortCount = Int(DOSPortCount.Text)
  ReDim npData(0 To nPortCount)
  lErrCde = AdxDioReadDiPorts(m_lDevHandle, nPortStart, nPortCount, npData(0))
我在PB里面函数的申明:
Function Long AdxDioReadDiPorts (ref Long DriverHandle,long dwPortStart,long dwPortCount,ref char pBuffer) LIBRARY "adsapi32.dll"调用:
  long nPortStart 
  nPortStart = 0
  long nPortCount
  nPortCount = 1
  char pBuffer
  pBuffer=space(1000)

  ErrCde = AdxDioReadDiPorts(ref DriverHandle, nPortStart, nPortCount, ref pBuffer)

备注(DriverHandle为设备句柄,能正常打开设备)
问题:1、我这么申明的时候,在函数调用的时候提示PB错误。。。请问函数申明应该怎么修改呢?
2、我应该怎么调用这个函数呢?
请各位大虾帮帮忙看看,在线等。。。呵呵

------解决方案--------------------
pb几?
10以下:
Function Long AdxDioReadDiPorts (Long DriverHandle,long dwPortStart,long dwPortCount,ref string pBuffer) LIBRARY "adsapi32.dll"

------解决方案--------------------
调用:
ErrCde = AdxDioReadDiPorts(DriverHandle, nPortStart, nPortCount, pBuffer)


------解决方案--------------------
ref char pBuffer
或者
ref char pBuffer[]
  相关解决方案