Solved

How to use macro in Visual Basic

Posted on 1998-11-20
7
235 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

809 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