LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Setting an array of text boxes equal to individual form text boxes

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Link Text Boxes on Form? Joyce Excel Discussion (Misc queries) 8 September 1st 09 06:20 AM
User Form Text Boxes - Copy format of text boxes NDBC Excel Discussion (Misc queries) 3 July 2nd 09 02:02 AM
Setting Property Values of Text Boxes within Forms SkyEyes Excel Programming 1 July 1st 05 07:06 PM
Form Text Boxes moving md2503 Excel Worksheet Functions 2 May 16th 05 07:57 PM
Re-setting the serial number of text boxes jngi Excel Programming 2 January 27th 04 12:18 PM


All times are GMT +1. The time now is 01:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"