Results 1 to 5 of 5

Thread: how to use arrays in VB property

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    3

    how to use arrays in VB property

    Hi All,


    i'm trying to read one text file , if the strings in text file matches to any of the type which is written in regular expression (which is in XML). i want to store all those in an array to print it later.


    Here is the code:



    ObjInvoice.Amount() = regEx.Replace(strStringToMatch, "$1$2$3$4$5")


    in the class file i have taken the property as



    Public Property Get Amount() As String
    Amount() = mstrAmount()
    End Property

    Public Property Let Amount(ByVal strAmount() As String)
    mstrAmount() = strAmount()
    End Property


    but it is giving error to me.


    can you please help me out what might me the reason for the error.

    and can you expalin how to use arays in the property.

    Thanks&Regards,
    B.

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: how to use arrays in VB property

    You have not defined Amount as a string array:
    Public Property Get Amount() As String()

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    3

    Re: how to use arrays in VB property

    Hi merri,

    thank for your comments ,

    i have modified my code to


    Public Property Get Amount() As String

    Amount() = mstrAmount()
    End Property

    Public Property Let Amount(ByVal strAmount As String)
    ReDim mstrAmount(10)

    mstrAmount(0) = strAmount
    End Property


    here its giving me type mismatch error ,
    can you please suggest me how to do it.

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: how to use arrays in VB property

    Code:
    Public Property Get Amount() As String()
        Amount = mstrAmount
    End Property
    
    Public Property Let Amount(ByRef NewValue() As String)
        mstrAmount = NewValue
    End Property

  5. #5

    Thread Starter
    New Member
    Join Date
    Aug 2008
    Posts
    3

    Re: how to use arrays in VB property

    i am calling that property from

    ObjInvoice.Amount() = regEx.Replace(strStringToMatch, "$1$2$3$4$5")



    ITS GIVING ERROR :

    TYPE MISMATCH:array or user defined type expected

    can i have your chat id (if no problem),so that i can contact when i have code issues.

    Thank you for the reply.

    From,
    B.

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