VBA is NOT the same as regular VB. There are things that do not work.
One of the problems you are going to run into is the data reception. mchid gives a callback and you need to feed it the handler for that. This is done using the 'addressof' function. i do not know if VBA supports that.
i need to take a look at some code i wrote , maybe it is portable to VBA. Alternatively we could use a timer to wait a fixed time and then just go fetch the data.
Something that most people don;t know is that you can instantiate 'missing' elements from VBA at runtime.
dim systimer as new timerdim timerflag as boolean = falsesub form_load systimer.interval = 10 systimer.enabled=falseend subfunction Exchange ( outgoing as string) as string ' write to probe here systimer.enabled=true launchtimer while not (timerflag) doevents wend ' read result here return resultend functionsub launchtimer timerflag = false systimer.enabled=trueend launchtimersub systimer_tick timerflag = true systimer.enabled=falseend sub
the above code sends the usb string and then starts the systimer. the code goes into a while wend loop and monitors a flag ( timerflag). when the timer expires it sets the flag and disables itself. Then you simply read.
this function 'exchange' takes a string and returns a string. since this is a monolithic function that does 'ping-pong' (string out , string in ) there is no risk for buffer overflows.
i have a piece of code that implements this on the probe. i believe it should be portable to vba.
give me a few days to dig it up ...