Solved

How to use macro in Visual Basic

Posted on 1998-11-20
7
241 Views
Last Modified: 2013-11-25
I want to use macro in VB which is common feature in variable value defination in C or Clipper. Ex :

x = 100
a = "x"

? a
Ans : x

? &a         (macro)
Ans : 100

How to use macro in VB. Please guide us with code and examples.
0
Comment
Question by:Aurokripa
7 Comments
 

Expert Comment

by:air3rlr
ID: 1445863
Are you asking how to declare variables in VB, if not give me an example of the clipper code and maybe I can help.
0
 
LVL 1

Expert Comment

by:rayford
ID: 1445864
No he is looking for what is commonly called "INDIRECTION" which has its roots in assembler.  Philosophically, since all higher level languages are basically front ends for assembly language indirection is usually supported in some way even if its only a mock up.  His example seemed pretty clear.  He wants to find the variable to hold the name of another variable and return the indirected value of the second variable by refering to the once removed variable in a "MACRO" Ampersand capacity..
0
 
LVL 1

Expert Comment

by:rayford
ID: 1445865
Offhand I have no idea but there is the chance of using a control to house the value like a textbox and refer to the textbox by name.  Here is the syntax.
A$="Text1"  'name of textbox control
MSGBOX form1.controls(A$).Text  
'displays the contents of textbox named "Text1" effectively uses A$ as a macro to display not the contents of A$ but the contents of the control named indirectly within A$.  Hope it helps.
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 2

Expert Comment

by:KJHDI12
ID: 1445866
This was easyer in VB3 as the exe wasn't Compiled code and we had some commands to use impreted code inside strings.

As far as i know, this isn't possible in the newer versions of visual basic.

The only way to get this to work would be to cheat a bit :>

Make 2 arrays. One for the variable name, and one for value, then make a function that searches for the variable name in one of the arrays and return the value in the other one (G(X)). Then create another one that saves a new variable, or changes an existing variable (S(X).

The code would then be:

Dim x as integer
x = 100
S("a","X")
msgbox G("a")    ' --> Would return 100

This is the closest i can get.

Mr. Fixit

0
 

Author Comment

by:Aurokripa
ID: 1445867
To,
Rayford

Thanks a lot. You have understood our problem exactly. I accept your suggetion. When I will implement it in my live application and if I required I will ask your help.

Thanks again

With warm regards,

Nilesh shah
Aurokripa softwares
0
 
LVL 9

Accepted Solution

by:
cymbolic earned 50 total points
ID: 1445868
I have used Clipper as well, and know the feeling of losing all the power that CLipper provided using via its "macro" capability.  Unfortunately, there is no comparable ability in VB. Clipper supported this capability by incorporating what they called a "run time compiler" in the product (gee, sounds like java, N'est pas?) but VB has nothing like this.  Clipper would support this internally by actually comiling lines of strings (clipper code) dynamically just before executing them ( hence the extension into code blocks teminology in later versions of clipper).

The closest you can come in vb is by creating functions of case statement branching, or using your own indirect pointers in arrays, etc.  Not as good, quite a bit messier in implementation and execution, but as good as you can get in this VB media.
0
 

Author Comment

by:Aurokripa
ID: 1445869
To,
Cymbolic

Hello. Thanks a lot. I understood the problem with the Clipper users in VB. This problem was one of them only. But we are so use to with highlty advanced and compitent language and switching over to Windows gives us day to day problem like that. But we have determine ourselves and working hard with it. So, let us see how is going !!
Even printing is a major subject. We try to give eveything userdefine in Entry and printing formats. So that thing also has to be covered !!
Meanwhile thanks a lot. I m glad that you atleast understood our problem cauze u r so familier with Clipper. Maile me personally if u feel to do communication.

With warm regards,

Nilesh shah
Aurokripa Softwares

0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question