ByRef Argument Type Mismatch" Error VB6

后端 未结 1 1374
深忆病人
深忆病人 2021-01-17 08:30

I am new to VB6 and spread.My VB project is making using of spread .In forms wherever the spread initialization is done,VB 6 is throwing a compile error as \"By Ref Argument

相关标签:
1条回答
  • 2021-01-17 08:57

    The "ByRef Argument Type Mismatch" error occurs when you are passing a parameter to a function that is using ByRef (the default) and the data type does not match what is expected.

    Private Sub MyMethod(ByRef Value As String)
      ...
    End Sub
    
    Private Sub OtherMethod()
      Dim Value As Integer
      MyMethod Value
    End Sub
    

    Note that Value is declared as Integer but the parameter is declared as String, and as such are a mismatched.

    Either correct the data types to match (Which way depends on what they are and their use), change the parameter to ByVal, or do both (the best option unless you explicitly want to use ByRef).

    If the calling code is not yours, then it's possible that the By... was ommited resulting in the VB6 default of ByRef even if it wasn't deliberate.

    0 讨论(0)
提交回复
热议问题