Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to develop a data input form that can test input variables for
validity. There are several inputs and I would like to use an array of text boxes so that the error checking code can be done in a loop. (The maximum and minimum values for each text box entry would also be arrays.) When I try to set an array of text boxes (defined as a global array) to the names of the individual text boxes (defined in the property windows of the user form) I get a type mismatch error. By debugging the code I see that the names of the individual text boxes on the right side of the equal sign are using their default property so they appear to be strings instead of objects. Here is an abbreviated version of the code I have used to test this concept: Option Explicit Const numberOfInputs = 3 Dim textBoxArray(1 To numberOfInputs) As TextBox Sub userForm_initialize() 'Here is where the type mismatch error occurs. Set textBoxArray(1) = txtA 'Text box names becomes strings at run time Set textBoxArray(2) = txtB Set textBoxArray(3) = txtC End Sub 'Goal is to have error checking in a loop over all text boxes Private Sub cmdSave_Click() Dim varNo As Integer For varNo = 1 To numberOfInputs Call checkInput(varNo) Next varNo End Sub Is there any way that I can set array components to refer to the scalar text box objects (txtA, txtB, txtC). Thanks for your help. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Link Text Boxes on Form? | Excel Discussion (Misc queries) | |||
User Form Text Boxes - Copy format of text boxes | Excel Discussion (Misc queries) | |||
Setting Property Values of Text Boxes within Forms | Excel Programming | |||
Form Text Boxes moving | Excel Worksheet Functions | |||
Re-setting the serial number of text boxes | Excel Programming |