Follow up: This VB code works fine:
For y = 0 To 10
For x = 0 To 10
Code "G0 Z1"
Code "G0 X" & x & "Y" & y
While IsMoving()
Sleep(10)
Wend
Code "G31 Z-10"
While IsMoving()
Sleep(10)
Wend
Sleep(10)
zProbe = GetDRO(2)
Message "x " & x & ", y " & y & ", z " & zProbe
Next
Next
It seems that the problem is related to timing issues. If I omit the sleep(10) before the GetDRO(2) call, I get spurious values for Z.
Based on this VB script, I developed a wizard that does the whole digitizing in VB. I will keep trying to resolve the issue in G-Code.
Thanks for your support.