Nothing99
asked on
Use a string to refered to an object
First, sorry for my poor english... My native language is french.
Now my question:
I need to have a function that return a string. Something like this:
Function test(p1 as integer) as String
Select Case p1
Case 1
test = "object1"
...
Case n
test = "objectn"
End select
End function
So if i use "test(2).name" i will access the name property of object2.
Sorry if it's confuse.
Vincent
Now my question:
I need to have a function that return a string. Something like this:
Function test(p1 as integer) as String
Select Case p1
Case 1
test = "object1"
...
Case n
test = "objectn"
End select
End function
So if i use "test(2).name" i will access the name property of object2.
Sorry if it's confuse.
Vincent
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
he says he wants to return a string...maybe he means this:
Function test(p1 as integer) as String
Select Case p1
Case 1
test = object1.name
...
Case n
test = objectn.name
End select
End function
now test will return the name of whichever object is selected according to the p1 value that is passed to the function. let us know if we're reading your question correctly.
however this wouldnt make much sense to have a control array as they all bear the same name (different indexes)
how does the p1 parameter reference a particular object? what is the correlation between the two?
Function test(p1 as integer) as String
Select Case p1
Case 1
test = object1.name
...
Case n
test = objectn.name
End select
End function
now test will return the name of whichever object is selected according to the p1 value that is passed to the function. let us know if we're reading your question correctly.
however this wouldnt make much sense to have a control array as they all bear the same name (different indexes)
how does the p1 parameter reference a particular object? what is the correlation between the two?
Public Function Text(p1 as Integer) as String
Text = me.Controls("object" & p1).Name
End Function
This may be what you are looking for, Me is referring to the Form
Text = me.Controls("object" & p1).Name
End Function
This may be what you are looking for, Me is referring to the Form
Dim str As String
str = test(3)
Msgbox str