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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mcriderConnect With a Mentor Commented:
"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
 
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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
 
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
 
leederAuthor Commented:
mcrider--you win--cheers
0
 
mcriderCommented:
;-)
0
 
Erick37Commented:
Gimme those points mcrider! :-/
0
 
mcriderCommented:
sorry... )
0
All Courses

From novice to tech pro — start learning today.