Results 1 to 3 of 3

Thread: Calling a function with textbox as input parameters

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    32

    Post

    I am making an applcn. wherein the properties of textboxes are changed dynamicaly.I can hard code all the text boxes .Is ther a way I can use a function to avoid this.

    I have 5 arrays of textboxes each of whose properties will be set at run time( properties like linkitem) so that I do not have to hard code it for all the forms.
    I want to have a function to which I can pass arrays of textboxes as parameters and use it in all the forms.


    Thanks


  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    One way would be to use the For..Each Statement to Enumerate all Textboxes on your Form(s), e.g.
    Code:
    Private Sub Form_Load()
        For Each Control In Me
            If TypeOf Control Is TextBox Then
                Control.Text = "Default Text"
            End If
        Next
    End Sub
    If you want this functionality for all or a range of your Forms, put the Routine into a Public Sub in a Module and have it passed a Reference to the Form, eg.
    Code:
    Public Sub SetDefaultProperties(ByRef oForm As Form)
        For Each Control In oForm
            If TypeOf Control Is TextBox Then
                Control.Text = "Default Text"
            End If
        Next
    End Sub
    The in each Forms Load Event use:
    Code:
    Private Sub Form_Load()
        SetDefaultProperties Me
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  3. #3

    Thread Starter
    Member
    Join Date
    Oct 1999
    Posts
    32

    Post


    Thanks,Young.

    What I was looking for is this :
    I have forms wherein there are 5 arrays which are linked to 5 different rows of an Excel Spreadsheet.
    As an example say string1(i) is linked from r1c1 to r1c10(Am using linkitem property of Textbox).String2(i) has to be linked to r2c1 to r2c10.I was looking for a way in which I just pass the names of the arrays and the function/procedure does the manipulations accordingly irrespective of the form.

    Thanks


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