Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dll &引用;编译错误语法错误“;调用函数_Dll_Visual Studio 2008_Vb6 - Fatal编程技术网

Dll &引用;编译错误语法错误“;调用函数

Dll &引用;编译错误语法错误“;调用函数,dll,visual-studio-2008,vb6,Dll,Visual Studio 2008,Vb6,我想在VB6中调用一个DLL,我在VisualStudio2008中有工作代码(示例程序) ==这是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, B

我想在VB6中调用一个DLL,我在VisualStudio2008中有工作代码(示例程序)

==这是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
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
==这是VB6代码====

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
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()在de VB6中已经是红色,表示存在错误)。这与“RunMotor1(200,50,0,0)”相同


看起来我的转换不正常…

无论发生什么,在VB6中,您不应该在
的参数周围使用括号,除非您还使用
调用
关键字。这适用于作为
Sub
s调用的
函数
s,换句话说:

 RunMotor1 200, 50, 0, 0
--或--

但从来没有

 RunMotor1 (200, 50, 0, 0)

VB.Net
Integer
是32位的,但是VB6
Integer
是16位的,在VB6
Long
中是32位的类型,所以在声明中使用它

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

Dim result as Long
result = InitStp()

谢谢,这很有效!现在的代码Private Declare函数InitStp Lib“stp.dll”()只要Private Declare函数RunMotor1 Lib“stp.dll”(ByVal步长长,ByVal间隔长,ByVal方向长,ByVal输出长)只要Boolean Private Sub Command1_Click()调用InitStp End Sub Private Sub Command2_Click()调用RunMotor1(200,50,0,0)末端接头