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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a property using a variable

Status
Not open for further replies.

LarryDK

Programmer
Dec 23, 1999
12
US
Can a property be referenced by a substituted variable?<br>
<br>
I want to be able to reference a property such as .width = 24 without including &quot;width&quot; but rather with a string or variant variable which I would assign &quot;width&quot; to.<br>
<br>
My actual situation is fields in a table which are like num1, num2, num3, etc. I have a case statement which works OK but if I can construct a variable like &quot;num&quot; & index where index is gathered from somewhere else I can reduce my code.
 
I think the very nature of any programming language will not allow it. That's what makes it a language, it has to recognize certain key words (command words) such as width.<br>
In some cases you can't just make the code any smaller that it is.<br>
The Select Case and the IF statement both work similarly in that the program flow will check each line until it finds a match. If you put a stop in your code and watch the following statements you will see it. Press F8 to move one line at a time.<br>
<br>
Dim a, somevalue As Integer<br>
a = 4<br>
Select Case a<br>
Case 1<br>
Case 2<br>
Case 3<br>
Case 4<br>
Case 5<br>
Case Else<br>
End Select<br>
<br>
If a = 1 Then<br>
ElseIf a = 2 Then<br>
ElseIf a = 3 Then<br>
ElseIf a = 4 Then<br>
ElseIf a = 5 Then<br>
ElseIf a = 6 Then<br>
End If<br>
<br>
a DO loop will get things smaller depending on what you are DO-ing. No pun intended.<br>
<br>
Somevalue =0<br>
Do<br>
If a = somevalue Then<br>
' Do something here<br>
Exit Do<br>
End If<br>
Somevalue= somevalue+1<br>
Loop<br>

 
OK WP<br>
So give us a real world example in Access.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top