Solved

How to use macro in Visual Basic

Posted on 1998-11-20
7
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

729 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