gpt4 book ai didi

winapi - VB6:运行时错误 '13':设置和 int 与 int 时类型不匹配

转载 作者:行者123 更新时间:2023-12-02 01:23:03 25 4
gpt4 key购买 nike

我对 VB6 编程并不陌生,但也不是它的高手。希望有人可以帮助我解决有关类型不匹配错误的问题,该错误是我在尝试使用函数返回的 int 设置 int 变量时收到的。

我尝试设置的整数定义为:

Global AICROSSDOCKStatus As Integer

现在,当我尝试进行此调用时,我收到运行时错误 13

AICROSSDOCKStatus = ProcessQuery(iocode, pb, AICROSSDOCBOLFN, "")

我已经逐行调试了程序。 ProcessQuery 函数获取并返回预期的整数,但是当要对 AICROSSDOCKStatus 进行赋值时,它会失败。

顺便说一句,我还尝试对 ProcessQuery 执行 CInt() 并获得相同的结果。

有人对我可以尝试的事情有什么建议吗?

编辑:这是ProcessQuery的定义

Function ProcessQuery(icode As Integer, pb As ADODB.Recordset, TableName As String, sql$) As Integer

编辑2:我无法告诉你为什么要这样做。我继承了代码库。哎呀...


Function ProcessQuery(icode As Integer, pb As ADODB.Recordset, TableName As String, sql$) As Integer
ProcessQuery = ProcessQuery1(icode, pb, TableName, sql$)
End Function

Function ProcessQuery1(icode As Integer, pb As ADODB.Recordset, TableName As String, sql$) As Integer
''THIS IS THE ORIGINAL SQL CALL ROUTINE!
Dim STATUS As Integer
On Error GoTo ProcessSQLError

STATUS = 0
Select Case icode
Case BCLOSE
If pb.State 0 Then
pb.Close
End If
Set pb = Nothing
STATUS = 3
Case BOPEN
STATUS = 9
Set pb = New ADODB.Recordset
Case BOPENRO
STATUS = 9
Set pb = New ADODB.Recordset
Case BGETEQUAL, BGETEQUAL + S_NOWAIT_LOCK, BGETGREATEROREQUAL, BGETGREATEROREQUAL + S_NOWAIT_LOCK
If pb.State 0 Then
pb.Close
''Set pb = Nothing
''Set pb = New ADODB.Recordset
End If
pb.Open sql$, MISCO_SQL_DB, adOpenDynamic, adLockOptimistic
If Not pb.EOF Then
pb.MoveFirst
Else
STATUS = 9
End If
Case BGET_LE, BGET_LE + S_NOWAIT_LOCK
If pb.State 0 Then
pb.Close
End If
pb.Open sql$, MISCO_SQL_DB, adOpenDynamic, adLockOptimistic
If Not pb.BOF Then
pb.MoveLast

Else
STATUS = 9
End If
Case BGETFIRST, BGETFIRST + S_NOWAIT_LOCK
If pb.State 0 Then pb.Close
sql = "select * from " + TableName
If InStr(1, gblOrderBy, "ORDER BY") > 0 Then
sql = sql + gblOrderBy
Else
sql = sql + " ORDER BY " + gblOrderBy
End If

gblOrderBy = ""
pb.Open sql$, MISCO_SQL_DB, adOpenDynamic, adLockOptimistic
If Not pb.EOF Then
pb.MoveFirst
End If
Case BGETLAST, BGETLAST + S_NOWAIT_LOCK
If pb.State 0 Then
pb.Close
End If
sql = "select * from " + TableName
If InStr(1, gblOrderBy, "ORDER BY") > 0 Then
sql = sql + gblOrderBy
Else
sql = sql + " ORDER BY " + gblOrderBy
End If
gblOrderBy = ""
pb.Open sql$, MISCO_SQL_DB, adOpenDynamic, adLockOptimistic
If Not pb.EOF Then
pb.MoveFirst
pb.MoveLast
End If
Case BGETNEXT, BGETNEXT + S_NOWAIT_LOCK: pb.MoveNext
Case BGETPREVIOUS, BGETPREVIOUS + S_NOWAIT_LOCK: pb.MovePrevious
Case B_UNLOCK
''need to add code here
Case BINSERT
If pb.State = 0 Then
pb.Open TableName, MISCO_SQL_DB, adOpenDynamic, adLockOptimistic
End If
Case BDELETE
STATUS = 8
pb.Delete
Case Else
STATUS = 1
MsgBox "STOP: UNDEFINDED PROCEDURE" + Str$(icode)
End Select
If STATUS = 0 Then
If pb.EOF Or pb.BOF Then STATUS = 9
End If

ProcessQuery1 = STATUS
Exit Function

ProcessSQLError:
MsgBox TableName + ": " + Error(Err), vbCritical, "Error "
ProcessQuery1 = 9

End Function

最佳答案

嗯,我不能说我知道出了什么问题,但这里有一个可能的调试步骤:首先分配一个本地定义的整数,然后将 AICROSSDOCKStatus 分配给本地 int。如果运行时错误 13 发生在第一次赋值时,那么就会发生一些非常奇怪的事情 - 如果它发生在第二次赋值时,那么您可能想看看是否有任何全局变量是可能超出界限的数组。

祝你好运!

关于winapi - VB6:运行时错误 '13':设置和 int 与 int 时类型不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/840548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com