Indirect Addressing

Visual Basic 3.0
When the following program is run...

A=1234
B$="A"
C=UnknownFunction(B$)

...what is the "UnknownFunction" that assigns the value of variable A (1234) to variable C by referencing variable B$ ?
leederAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mcriderCommented:
Visual Basic 3 doesn't have indirect referencing... Sorry.

Cheers!
0
Erick37Commented:
Dim A As Long
   
Private Sub Form_Load()
    Dim B As String
    Dim C As Long
    A = 1234
    B = "A"
    C = UnknownFunction(B)
    Debug.Print C
End Sub

Private Function UnknownFunction(sVar As String) As Long
    Select Case sVar
    Case "A"
        UnknownFunction = A
    '... more cases
    Case Else
        UnknownFunction = 0
    End Select
End Function
0
leederAuthor Commented:
Thanks for your rapid response.  However, you must realize that it is too early for me to accept such an answer.  The old old dBase II programming language had such a function and I still have hopes of a solution.  I must wait for other responses although you may be absolutely correct.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
Erick37's comment shows a way for you to "do-it-yourself".

In his example, you would have to program a case statement for each indirect reference.

Cheers!
0
Bob LearnedCommented:
This functionality seems to be common in XBase languages, such as FoxPro and dBase, but you will not find a single internal VB3 function that will solve your problem.  You would have to write a function, like Erick37 suggested that simulates this.  

VB6 Professional/Enterprise has a Micro$oft Script Control that does expression evaluation that would do the trick, but this doesn't help with VB3.
0
leederAuthor Commented:
To Erick37 (and mcrider)

Your response certainly works for fixed known variables (it is how I currently am doing it) however, it requires a programming modification every time a different variable is used.  
Although my example may be simplistic, I need something that will encompass any variable name.
0
Erick37Commented:
If VB3 has SaveSetting and GetSetting:

Dim A, C As Long
Dim B As String
A = 1234
SaveSetting "AppName", "Indirect", "A", A
B = "A"
C = GetSetting("AppName", "Indirect", B, 0)
Debug.Print C
0
mcriderCommented:
I stand by my original answer (as confirmed by TheLearnedOne) VB3 does not contain any NATIVE way of performing this function.


Cheers!
0
mcriderCommented:
TheLearnedOne... By the way, the microsoft Script control MSSCRIPT.OCX is available for VB4-32-bit and VB5 from a microsoft download page, and is shipped with VB6...

Cheers!
0
mcriderCommented:
Erick37, Using the Registry like this will DEFINATELY increase the size of the registry (and boot time?)...

Cheers!
0
Erick37Commented:
Yes, Mcrider, I would not use this approach for many operations.  But if I HAD to do it for a couple of variables on occation, it would work.  Just a comment.
0
leederAuthor Commented:
mcrider--I am still not quite convinced.  Also, I don't have to have a "Native" solution - 3rd party would be fine.

Erick37--VB3 doesn't seem to have "SaveSetting" or "GetSetting"

0
Bob LearnedCommented:
You are definitely stretching the rubberband pretty thin.  I haven't thought about VB3 for about 4 or 5 years, and I hope that you find an answer to your question that you are going to accept.
0
mcriderCommented:
"SaveSetting" & "GetSetting wern't implemented until VB4 If you want to take the registry route, you'll have to use API calls...

an example of VB3 registry calls is in:

VB3: How to Associate a File Extension with Your Application
http://support.microsoft.com/support/kb/articles/Q119/2/81.asp
 
Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
leederAuthor Commented:
mcrider--you win--cheers
0
mcriderCommented:
;-)
0
Erick37Commented:
Gimme those points mcrider! :-/
0
mcriderCommented:
sorry... )
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.