Your big problem is going to be keeping the values between changes. Remember, every time VB runs a button or a macro it starts a NEW VB process. So anything you stored in an array the last time a tool changed is lost, VB starts a new array.
You could define a series of Mach DROs, one for each tool pocket. Then any time your code runs it looks at each DRO to find the one holding the tool number it wants, then it sets that DRO to the number of the tool its about to put in that pocket.
DROs and LEDs are maintained by mach for each screenset. The macros will see the DROs that belong to the current screen when they run. Watch out for weird things happening if you should run one of those macros from a wizard screen! Also an issue when a macropump is running, it shares its DROs and KEDs with the current screen, so running a wizard or screenset that is not coordinated with the macropump is also risky.
I have been beating on Brian to fix this so there would be one Vb context started up every time a screen loads, then every button call would simply be a subroutine call in that context. He agrees its a worthy change, but it looks like a major change. I will keep pressing him.
ron ginger