This code I'm working on works in conjunction with SolidWorks but the problem exists in vba. A bit of context first. I have two text boxes that show information regarding two different object selections. The first text box, controlpath, shows the name of the sketch selection. The second textbox, object, shows the name of an extrusion object and also displays the parent object to the selection in a 3rd text box, terminating object. When I click on either the 1st or 2nd text box, I have a Do While Loop that loops until I make a selection in SolidWorks. When a selection has been made, a subroutine runs to retrieve information. This information is displayed in the text box and I exit the Do Loop if the selection is valid. Outside of the Do While Loop I have a call back into the same textbox MouseUp event that I was currently in. This is done so that my MouseUp event remains triggered so that the user can make a different selection for that text box without having to click back in it. I would like to keep this feature. Also, at anypoint in the Do While Loop the user can select the other text box, which has basically the same looping code/MouseUp event call. When an object has been selected for the 2nd text box, the 3rd text box unlocks and I can click on it and this object is highlighted (selected) in SolidWorks. If I click on the 3rd text box and when it's MouseUp event private sub ends, I drop back into the previous text boxes Do While Loop.
Herein lies the problem. When I click into another text box, while I'm in a different text box looping, is there a way to exit text box A's MouseUp event from text box B's? Is there a better way of coding a text box to continually have a MouseUp event until I select a different text box?
pseudo code:
Private Sub objTxtBox_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Do While objSelection < 2
DoEvents
GetObjName objSelection
objname.text = objSelection.name
If validsel = true then
Exit Do
End if
Loop
objTxtBox_MouseUP(1,0,X,Y)
end sub
Private Sub sketchTxtBox_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
Do While sketchSelection < 2
DoEvents
GetObjName sketchSelection
sketchname.text = sketchSelection.name
If validsel = true then
Exit Do
End if
Loop
sketchTxtBox_MouseUP(1,0,X,Y)
end sub
Bookmarks