Results 1 to 7 of 7

Thread: [RESOLVED] Make a function return a array

  1. #1

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Resolved [RESOLVED] Make a function return a array

    Hi. I want my function to return a array.
    I got this error: Compile error: Type Mismatch.

    This is my code:

    Code:
    
    Public Function RegistaNBCobranca(Entidade As Integer, ContaBancaria As String, TipoDoc As String, Serie As String, NumDoc As Long, Prestacao As Integer, Valor As Double, DataDoc As String) As String
    Dim Recibo As GcpBEDocumentoLiq
    
    Dim Retorna(1 To 2) As String
    
    With Recibo
         '....
         '....
         Retorna(1) = .NumDoc
    End With
    Retorna(2) = Recibo.Serie
    RegistaNBCobranca = Retorna()
    End Function
    What's wrong with my code?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Make a function return a array

    What is GcpBEDocumentoLiq?

    How do you call your function?

    What line causes the error?

  3. #3
    Fanatic Member amrita's Avatar
    Join Date
    Jan 2007
    Location
    Orissa,India
    Posts
    888

    Smile Re: Make a function return a array

    Modify this as
    Code:
    Public Function RegistaNBCobranca(Entidade As Integer, ContaBancaria As String, TipoDoc As String, Serie As String, NumDoc As Long, Prestacao As Integer, Valor As Double, DataDoc As String) As String
    
    '--Add this
    Public Function RegistaNBCobranca(Entidade As Integer, ContaBancaria As String, TipoDoc As String, Serie As String, NumDoc As Long, Prestacao As Integer, Valor As Double, DataDoc As String) As String()
    
    Dim Recibo As GcpBEDocumentoLiq
    
    Dim Retorna(1 To 2) As String
    
    With Recibo
         '....
         '....
         Retorna(1) = .NumDoc
    End With
    Retorna(2) = Recibo.Serie
    '--RegistaNBCobranca = Retorna()
    '--Add this
    RegistaNBCobranca = Retorna
    
    End Function

  4. #4
    Fanatic Member Dnereb's Avatar
    Join Date
    Aug 2005
    Location
    Netherlands
    Posts
    863

    Re: Make a function return a array

    Public Function RegistaNBCobranca(Entidade As Integer, ContaBancaria ...., DataDoc As String) As String()


    End Function
    why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
    for every question you ask provide an answer on another thread.

  5. #5

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Re: Make a function return a array

    Hi. 1st: GcpBEDocumentoLiq is a type of data.
    2nd: I got the error in the line last line:
    Code:
    RegistaNBCobranca = Retorna()
    3rd: When i try to compile (it's a dll) i got that error of type mismatch.
    Thanks.

  6. #6

    Thread Starter
    Hyperactive Member RS_Arm's Avatar
    Join Date
    Mar 2007
    Location
    Planet Earth
    Posts
    282

    Resolved Re: Make a function return a array

    Ok. Thats resolved. It was the lack of ().
    Thank you all for your quick replyzz.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Make a function return a array

    The easiest and best way to mark a thread resolved is to pull down the Thread Tools menu and click the Mark Thread Resolved menu item.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width