Click to See Complete Forum and Search --> : Calling a function with textbox as input parameters
shastri_s
Nov 15th, 1999, 02:01 AM
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
Aaron Young
Nov 15th, 1999, 02:11 AM
One way would be to use the For..Each Statement to Enumerate all Textboxes on your Form(s), e.g.
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.
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:
Private Sub Form_Load()
SetDefaultProperties Me
End Sub
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
shastri_s
Nov 15th, 1999, 09:44 PM
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
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.