Solved

How to use macro in Visual Basic

Posted on 1998-11-20
7
230 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

760 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

18 Experts available now in Live!

Get 1:1 Help Now