|
-
Dec 22nd, 2001, 11:27 AM
#1
Thread Starter
Lively Member
Syntax question...
I need to reference a control array from a string variable, but the fact that it is an array is causing a syntax problem. This may explain it better...
THIS WORKS (if I have a text box named txtTest):
Code:
Public Sub ChangeText()
Dim sControlName as String
sControlName = "txtTest"
Me(sControlName).Text = "foobar"
End Sub
THIS DOESN'T WORK (if I have a text box array with txtTest(2)):
Code:
Public Sub ChangeText()
Dim sControlName as String
sControlName = "txtTest(2)"
Me(sControlName).Text = "foobar"
End Sub
Any help would be most appreciative!
Jeff
-
Dec 22nd, 2001, 11:47 AM
#2
Frenzied Member
This does work...
VB Code:
Dim sControlName As String
sControlName = "txtTest"
Me(sControlName)(2).Text = "foobar"
Greg
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
-
Dec 22nd, 2001, 12:04 PM
#3
Thread Starter
Lively Member
SUPER Greg!
Thanks a bunch!
Jeff
-
Dec 22nd, 2001, 12:14 PM
#4
Another way you can do this:
VB Code:
Dim sControlName
Set sControlName = txtText(2)
sControlName.Text = "foobar"
-
Dec 22nd, 2001, 12:18 PM
#5
Forgot to add this for control array:
VB Code:
Dim sControlName
Dim intCount As Integer
Set sControlName = txtText
For intCount = 0 To 2
sControlName(intCount).Text = "foobar"
Next intCount
Set sControlName = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|