Call it my lack of experience with VB6, but I can't understand why my code (sample below) is giving me a Type Mismatch error when I use the Fields argument in my call to write things to a debug log. Can anyone help or explain?

Public Sub Update(ByRef myChain As cChain, ByVal Index As Long, ByVal myID As Long, ByRef Fields() As String, ByRef Values() As String)
    Call WriteToDebugLog("Update - Index: " & Index & ", myID: " & myID & ", Fields: " & Fields)
End Sub

BTW, my WriteToDebugLog() routine takes ByVal str1 As String as it's argument.

Edited 6 Years Ago by roachae: added last line

Well, without seeing the actual code that calls this function it is kind of hard to tell but I'm guessing that you are getting you error because you are not passing a cChain variable or not passing actual arrays...

Good Luck

Hi,

Not sure... but all these are Key words in VB6.. Try adding some prefix to them, so that compiler and yourself dont get confused....:

Update
Index
Fields

Also noted: "Fields() and Values()" are supposed to be arrays.. but you nextline of code dosent treat them like arrays :
Call WriteToDebugLog("Update - Index: " & Index & ", myID: " & myID & ", Fields: " & Fields)

If they are not arrays, then pass remove brackets from argument..
if they are arrays, then change to MyFields(0)..

Regards
Veena

The actual code isn't using what I showed above (call it pseudo-code what I showed... keywords are not really being used), and I only showed the one line I added to an already existing routine that uses what I'm trying to use (basically the "Fields" variable, which is being used in the existing code the same way I'm trying to use it). Everything else except the call to WriteToDebugLog() is existing code (not written by me, and the original designer that wrote it is long gone from the company I work for) that has worked for years.

Hi,

So, Are you Passing arrays to arguments 'Fields" and "Values"....?
If not, then you will get error...

Regards
Veena

Yes, they are arrays... but even if I try to use "Fields(0)" in my call to WriteToDebugLog(), I still get the mismatch error.

Hi,

So, Are you Passing arrays to arguments 'Fields" and "Values"....?
If not, then you will get error...

Regards
Veena

Basically the function/method WriteToDebugLog(ByVal str1 As String) do not accept an array data.

I understand that, but there are existing lines of code that I did not include above that uses those arrays as I am trying to (as strings) and that code has worked for years. Like I said above, the original designer that wrote it is long gone from the company. That's what I can't understand.

Basically the function/method WriteToDebugLog(ByVal str1 As String) do not accept an array data.

Want to pass an array??? Array arguement must be byref...

Private Sub mysub(ByRef mystringarray() As String)

End Sub

Good Luck

This article has been dead for over six months. Start a new discussion instead.