Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've got a legacy VBA function which I want to stop running if it takes longer than 3 minutes - please see below for code I have so far.

Obviously, the MsgBox only shows once function has completed but I need it to show and exit a function during.

        Dim startTime As Long
        startTime = GetTickCount

        Do

            If GetTickCount - startTime > 10000 Then
                MsgBox "There seems to be an issue. Please try again!"
                Exit Do
            End If

            doStuff

        Loop

Can anyone help me out?!

Many Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
181 views
Welcome To Ask or Share your Answers For Others

1 Answer

If the code is in that same sum you can just add Exit Sub after your msgbox.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...