Hey guys,

I'm trying to send an array as a parameter and it is not working....
I have set it to passed by reference in my sub.
Visual Basic says:

"Compile error:

Type mismatch: array or user-defined type expected"

How may i solve this problem?

Yours words of wisdom are greatly appreciated.
Thanks.

Recommended Answers

All 3 Replies

Hi, Can u post your sub routine or its prototype?

Dim index, length, Shift(0 To 30), loopcount As Integer
Dim codeword, wordtoencrypt As String

Private Sub cmdEncrypt_Click()
codeword = LCase(txtCodeword.Text)
wordtoencrypt = LCase(txtData.Text)

Call CalcShift(codeword, [B]Shift()[/B])

lblOutput.Caption = Shift(0)
End Sub

Public Sub CalcShift(ByVal word As String, ByRef ArrayShift() As Integer)
    
    For loopcount = 0 To Len(word)
        index = 0
        Call CheckLetter(Mid(word, loopcount, 1), letter)
        If letter Then
            flag = False
            While flag = False And index < 26
                If Mid(codeword, loopcount, 1) = Alphabet(index) Then
                    ArrayShift(loopcount) = Alphabet(index)
                    flag = True
                End If
                
                index = index + 1
            Wend
            
        End If
        
    Next Count
    
        
End Sub

The error occurs when I try and send the array, Shift(), to the procedure CalcShift.
I have bolded the Shift() for you to see.

Thanks.

Hey thanks for your help. I figured it out.I just changed the the Public Sub to Sub and it worked

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.