Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CONVERT STRING TO OBJECT 1

Status
Not open for further replies.

lazytrucker

Programmer
Aug 4, 2004
39
0
0
GB
Hi all, is there a stored procedure or method for converting a string to an object??
The context in which I am trying to do this is as follows:

For i = 1 To 3
"UserForm1.TextBox" & i & ".Visible" = False
Next
UserForm1.Show


This obviously doesnt work but is essentially what I am attempting to do.

If any one has any suggestions they would be greatly appreciated.

Cheers LazyTrucker
 
Hi lazytrucker,

No! is the answer to your question. However, if what you are trying to do is reference controls when you have their names as strings, you can do it using the controls collection, something like ..

Code:
[blue]Userform1.Controls("Textbox" & i).Visible = False[/blue]

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
Not sure if this will work, but have you tried
Code:
Sub test()
For i = 1 To 3
a = "UserForm1.TextBox" & i
a.Visible = False
Next
UserForm1.Show
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top