dll - "Compile Error Syntax error"调用函数

标签 dll visual-studio-2008 vb6

我想在 VB6 中调用 DLL,并且我在 Visual Studio 2008 中有工作代码(示例程序)。

==== 这是 Visual Studio 2008 代码 ====

Declare Function InitStp Lib "stp.dll" () As Integer
Declare Function RunMotor1 Lib "stp.dll" (ByVal steps As Integer, ByVal interval As Integer, ByVal direction As Integer, ByVal outputs As Integer) As Boolean

Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Stop1.Click
  InitStp ()
End Sub

Private Sub Command2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Stop1.Click
  RunMotor1 (200, 50, 0, 0)
End Sub

====这是VB6代码====

Private Declare Function InitStp Lib "stp.dll" () As Integer
Private Declare Function RunMotor1 Lib "stp.dll" (ByVal steps As Integer, ByVal interval As Integer, ByVal direction As Integer, ByVal outputs As Integer) As Boolean

Private Sub Command1_Click()
  InitStp ()
End Sub

Private Sub Command2_Click()
  RunMotor1 (200, 50, 0, 0)
End Sub

当我尝试运行 InitStp() 的代码时,出现“编译错误语法错误”(代码 InitStp() 在 VB6 中已经是红色,表明存在错误)。这与“RunMotor1 (200, 50, 0, 0)”相同。

看起来我的转换不太好...

最佳答案

VB.Net Integer 是 32 位,但 VB6 Integer 是 16 位,在 VB6 Long 中是 32 位类型,因此使用在你的声明中。

InitStp ()

语法无效,请删除括号并单独使用 InitStp - 但这会忽略返回值,这通常不是一个好主意,因此:

Dim result as Long
result = InitStp()

关于dll - "Compile Error Syntax error"调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47431427/

相关文章:

.net - Azure Functions 在 bin 内创建另一个 bin 文件夹

sql - 如何使用 Visual Studio 2008 Server Explorer 将主键索引重置为 1?

visual-studio-2008 - VSTS 2008 测试版中的数据驱动验证规则

postgresql - PostgreSQL ODBC连接SSPI身份验证失败

forms - VISUAL BASIC 6::使用计时器卸载 Splash 表单

windows - 如何在 VB6 中执行更多代码之前等待 shell 进程完成

c# - 在 WPF 中处理来自 c++ dll 的未处理异常

c# - C++ 回调将文本发送回 C#

c++静态 vector 在DLL中丢失元素

c++ - 设置类忽略定义的 comp fn 和默认比较错误