Solved

How to use macro in Visual Basic

Posted on 1998-11-20
7
232 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create a duplicate finder Application 9 115
What is MicroStrategy.NET? 2 58
What .NET website keeps me current? 9 57
Macro Excel - Multiple If conditions 2 65
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now