If you want to run a macro alongside GCode, then the macro must be written and then put in the correct folder so that Mach3 knows where to look for it. If you are using a Mill screen, then the folder is Mach3/macros/Mach3mill.
VB is a good program, in that you can check all your code before posting it, by stepping through the program. If the program won't step there is a fault, and it should be highlighted, or the cursor stops at the right place.When you first load the GCode, Mach 3 reads the program, complete with macros and displays it on the toolpath, so it gives you an idea whether you are right or not.
Be careful, because if the machine is attached and on, the machine will move in response to " Code" instructions. I write all my VB on a different computer, where I have Mach 3 installed, but not connected to any machine. In this way I can run the complete GCode, with Macros.
If you look at the video tutorial on scripting and copy say the part where you download the tool change position from the user DRO's for a test, this will get you going. Rather than writing complex codec, keep it simple, using easily recognisable variables. Then do the maths, and then write out the code to the machine. This is one of my macros for rounding off a bar.
Rem Round End swinging arm
Code "G0 Z-17"
For depth = 0 To 10 Step 0.25
xpos = 26.34 - depth
Code "G0 X"&xpos
Code "G1 F25 Y15"
Code "G0 X"&(xpos+1)
Code "G0 Y-1"
Next depth
For getting parameters from DRO, write them into variables first named something like oldxpos, oldypos, oldzpos usiing simple instructions like
oldxpos = GetOemDro(**)
OR
newxpos = GetUserDRO(***)
do whatever you want with it, then either post it back to Mach3 e.g. SetVar(10,newxpos) or write the code for the machine to run using Code"G1 X"&newxpos &"Y"&newypos etc.
the machine runs as though you are writing the code on the MDI line, the only drawback being that you cant see it, the program just shows the macro number, not the macro itself.
I write some comments in the VB for the macro to post to the machine and it appears on the comments line, to let me know whereabouts the macro is, since some of them take an hour to run, where they are thinning down bar stock, then putting the profile on.
Stick at it.
If you email me and tell me what it is you want to do exactly, I will write some code for you, but I am a bit busy for the next three weeks, although I have some free evening time this first week.