Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   Index   Templates   Seminars   TechHelp   Forums   Help   Contact   Join   Order   Logon  
 
Home > TechHelp > Directory > Access > Variables < Gift Certificates | Multi-Table Forms >
Back to Variables    Comments List
Convert Text to variable Upload Images   Link   Email  
Joseph Quander       
2 months ago
I concatenated text from an array and specific text, like "ABC". I had hoped I could get it to show the value of a variable with the same name.
Sami Shamma             
2 months ago
Please rephrase your question I'm not getting what you are asking
Joseph Quander       
2 months ago
I have a variable called "lngRed" which is equal to RGB(255,0,0).  I have an array that one item that has an input named "Red".  I concatenated "lng"&"Red" to get lngRed,  but it is treated as text value and not the variable of the same name.
Joseph Quander       
2 months ago
Oh and the script is under the Form_Load.
Kevin Yip       
2 months ago
VBA does not have that capability.  To do it, you have to code it yourself, such as with a custom function:

     Function GetValue(s As String) As Variant
         Select Case s
             Case "ABC": GetValue = ABC
             Case "lngRed": GetValue = lngRed
             ' Do the same with all variables that you need this to be done to.
             ' If you have 100 different variables, you need 100 lines here.
         End Select
     End Function


If you are unfamiliar with custom functions and Select...Case, this site has videos on them.  The above function returns different values depending of the value of a variable.  In the above code, if the string s is "ABC", it returns the value of the variable ABC, and so on.

With the above function, you can retrieve a variable's value with a string of the variable's name:

     V = GetValue("lng" & "Red")

It's a cumbersome method, as you see.  Most people would find other means to accomplish the same end goal.  That depends on your goal.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Variables.
 

 
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2024 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 4/14/2024 6:44:36 AM. PLT: 1s
xxx