It depends what the LED is doing. Is it a standard Mach3 LED, or a custom LED for a special purpose?
For most standard mach3 LED's, there are button "calls" to turn them on. For a "User" LED, you just use code in the button to turn it on or off.
Also, you can't "latch" a button, but you can have it turn something on so that it stays on.
Basically, when you create a button, you assign a function to it. You have a few options.
1. Built in Mach function. There's a drop down list in Screen4 to choose them, and there are quite a few.
2. Call an OEM code. You just put the code in that does what you want it to do. There are codes for all the built in functions, so both 1 and 2 do the same thing, but 1 is just quicker if the function call is listed.
3. Run G-code. Just enter the g-code you want the button to do. I think it's limited to a single line of code, but you can also call M codes, so you can run a macro by calling it's code, such as M777.
4. Run VB script. This is probably the route you want to take, from what I gather from your post.
All the OEM codes can be found here. Look under #9.
One thing to understand in Mach3, is that turning on an LED actually activates that function. For example, the OEM LED code for Flood coolant is 13. So, if you want to turn on flood coolant with a button, you can use 2 of the methods I gave above.
1. Choose Flood from the built in function list.
4. Use the script SetOEMLED(13,1). SetOEMLED(13,0) would turn it off.
Method 2 requires an OEM button code, so you wouldn't use 13 there. The button code to toggle flood is 113. NOte that some button codes toggle on and off, while others are strictly on or off.
If you give me more specifics on what you want to do, I can give you a better answer.