+ Reply to Thread
Results 1 to 4 of 4

declaring Arrays to use in a Form with few modules

  1. #1
    coco
    Guest

    declaring Arrays to use in a Form with few modules

    How can I declare an Array in a form that will function as "Public". Those
    arrays values can be updated for every modules that is called when this form
    runs.?

    I have an example:

    This array will be like:

    ReDim ErrorValue(1 To Len(myVal)) As String

    *I need it PUBLIC because those array values are going to be updated in each
    of the following functions:

    function check4code1()

    frmCheckCells.ErrorValue(k) ="Type 1" 'for check4code1

    end function


    function check4code2()

    frmCheckCells.ErrorValue(k) ="Type 2" 'for check4code2

    end function

    ….and More functions….


    if no error is found then ErrorValue will be “”

    Then, at the end of the process. The form will have a result like this

    Sub searchX()

    lbltxtErrorFound=ErrorValue(0) + ErrorValue(1) +ErrorValue(2)……
    ….

    End sub


    Can it be the best option ?

    Thanks

    Coco


  2. #2
    Gareth
    Guest

    Re: declaring Arrays to use in a Form with few modules

    I'm not sure I understand your problem exactly but... you could just
    declare your variable at the top of a standard module, rather than in
    the form.

    Public ErrorValue() as string

    Then, redimension it whenever the form loads:

    ReDim ErrorValue(1 To Len(myVal)) As String

    (I'm not clear what myVal is here.)

    Gareth


    coco wrote:
    > How can I declare an Array in a form that will function as "Public". Those
    > arrays values can be updated for every modules that is called when this form
    > runs.?
    >
    > I have an example:
    >
    > This array will be like:
    >
    > ReDim ErrorValue(1 To Len(myVal)) As String
    >
    > *I need it PUBLIC because those array values are going to be updated in each
    > of the following functions:
    >
    > function check4code1()
    > …
    > frmCheckCells.ErrorValue(k) ="Type 1" 'for check4code1
    > …
    > end function
    >
    >
    > function check4code2()
    > …
    > frmCheckCells.ErrorValue(k) ="Type 2" 'for check4code2
    > …
    > end function
    >
    > ….and More functions….
    >
    >
    > if no error is found then ErrorValue will be “â€
    >
    > Then, at the end of the process. The form will have a result like this
    >
    > Sub searchX()
    > …
    > lbltxtErrorFound=ErrorValue(0) + ErrorValue(1) +ErrorValue(2)……
    > ….
    >
    > End sub
    >
    >
    > Can it be the best option ?
    >
    > Thanks
    >
    > Coco
    >


  3. #3
    DM Unseen
    Guest

    Re: declaring Arrays to use in a Form with few modules

    I suspect a collection would be better

    in frmCheckCells. code module

    Public Errors as New Collection


    the following would change to
    function check4code2()
    ....

    frmCheckCells.Errors.add "Type 2","Type 2"


    end function


    Then

    Sub SearchX()

    lbltxtErrorFound = ""
    For eacht strError in Errors
    lbltxtErrorFound = lbltxtErrorFound+ strError
    next strError

    End sub

    DM Unseen


  4. #4
    Gareth
    Guest

    Re: declaring Arrays to use in a Form with few modules

    Nice!

    DM Unseen wrote:
    > I suspect a collection would be better
    >
    > in frmCheckCells. code module
    >
    > Public Errors as New Collection
    >
    >
    > the following would change to
    > function check4code2()
    > ...
    >
    > frmCheckCells.Errors.add "Type 2","Type 2"
    >
    >
    > end function
    >
    >
    > Then
    >
    > Sub SearchX()
    >
    > lbltxtErrorFound = ""
    > For eacht strError in Errors
    > lbltxtErrorFound = lbltxtErrorFound+ strError
    > next strError
    >
    > End sub
    >
    > DM Unseen
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1