Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
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
Find 2 lowest point to form a trendline Elton Law[_2_] Excel Worksheet Functions 0 April 11th 10 03:54 PM
Form Letter and Embeded Word Object Aaron Excel Discussion (Misc queries) 2 July 15th 06 01:22 AM
How do I resize a check box form object in Excel? bpoole Excel Discussion (Misc queries) 1 May 11th 06 06:38 PM
Way of making an object with a greater number be given a point.... petros89 Excel Discussion (Misc queries) 3 October 6th 05 10:41 AM
Linking an object in power point to a excel worksheet jth Excel Discussion (Misc queries) 3 July 24th 05 02:16 AM


All times are GMT +1. The time now is 07:25 AM.

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

About Us

"It's about Microsoft Excel"