Pass parameters in a VB6 application

1

How do I pass parameters in VB6?

Private Sub Command1_Click()
    Dim cnpj As String
    cnpj = "tal"

    Dim chaveCliente As String
    chaveCliente = "tal"

    Dim chaveAcesso As String
    chaveAcesso = "tal"

    Dim status As String
    status = ""

    Dim protocolo As String
    protocolo = ""

    Dim motivoRejeicao As String
    motivoRejeicao = ""

    Dim objFuncao As Funcao

    Set objFuncao = New Funcao

    objFuncao.Consultar(ByVal cnpj As String)

Since Funcao was added as a reference to a COM created in .NET. It is giving syntax error, but everywhere I looked for the syntax of sending parameters is the one that is in the code.

Are there any other alternatives or am I doing wrong?

    
asked by anonymous 03.02.2014 / 18:47

1 answer

1

The syntax error is on this line:

objFuncao.Consultar(ByVal cnpj As String)

The correct one would simply be:

objFuncao.Consultar(cnpj)

This format is used in the function signature:

ByVal [nome variável] As [Tipo Variável]
ByRef [nome variável] As [Tipo Variável]

Being ByVal is the default and can be omitted.

Example:

Private Function Soma(ByVal x As Integer, ByVal y As Integer)
    Soma = x + y
End Function

[..]
    z = Soma(1, 2)

Recommended reading: link

    
06.02.2014 / 20:55