+ Reply to Thread
Results 1 to 3 of 3

Ending Do While Loop out of a sub

  1. #1
    Registered User
    Join Date
    12-14-2018
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    26

    Ending Do While Loop out of a sub

    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:

    Please Login or Register  to view this content.
    Last edited by roldy; 01-22-2020 at 12:24 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Ending Do While Loop out of a sub

    Where is the Loop command?

    I don't think your code is looping. VBA is single threaded; Meaning it's not looping one procedure while running another. It only runs one command at a time. You can switch between procedures, but you cannot run two procedures simultaneously.
    Last edited by AlphaFrog; 01-22-2020 at 12:28 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    12-14-2018
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    26

    Re: Ending Do While Loop out of a sub

    Oops. I corrected the original post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Never Ending Loop
    By oggyoggy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-26-2019, 03:42 PM
  2. Help on ending Loop
    By TimBrowne in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-11-2016, 07:28 AM
  3. [SOLVED] Do Until loop not ending
    By Dralky in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-15-2014, 09:57 PM
  4. Do until Loop not ending
    By Alexm963 in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 12-28-2012, 05:09 PM
  5. [SOLVED] ending a sub FOR loop in a main FOR loop
    By samkumar in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 09-27-2012, 05:35 AM
  6. Ending a Loop
    By kirsty in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 11-25-2010, 01:11 PM
  7. Never ending loop
    By Theodjinn in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-23-2008, 04:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1