Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using a string to point to a form object?
Hi,
How do I make a string that points to a form object. I have a form with many input textboxes and I would like to make a code using a for....next to check the input. For example, i have 20 textboxes named tb_input1, tb_input2 ..etc. How can I make this idea work For i=1 to 20 string="tb_input" & i form.string.value=10 next i VBA wont accept this at all. I have tried using the Object data type, but to no avail. Can anybody help? Regards, Plumbye |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Using a string to point to a form object?
Try the following, which should give you some ideas...
Create a form with three text boxes, and one command button: txt_1 txt_2 txt_3 CommandButton1 Copy the code below behind the command button: Private Sub CommandButton1_Click() Dim i As Integer Dim txtSource As MSForms.TextBox Dim strTest As String For i = 1 To 3 Set txtSource = Me.Controls("txt_" & i) strTest = txtSource.Text Next i Set txtSource = Nothing End Sub Not very elegant, but it will give you the values in teh text boxes. All you need to do is refer to the controls collection with the correct name - this type of reference will also work with dynamically created controls. HTH Please remove NOSPAM to email, and please post any replies directly to group. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Find 2 lowest point to form a trendline | Excel Worksheet Functions | |||
Form Letter and Embeded Word Object | Excel Discussion (Misc queries) | |||
How do I resize a check box form object in Excel? | Excel Discussion (Misc queries) | |||
Way of making an object with a greater number be given a point.... | Excel Discussion (Misc queries) | |||
Linking an object in power point to a excel worksheet | Excel Discussion (Misc queries) |