开发者

Conditional In For-Loop Escapes Sub

开发者 https://www.devze.com 2023-01-03 08:43 出处:网络
My code is as follows: sub main() \'\'\'some more code\'\'\' For j = InStr(1, stext, \" \") To Len(stext)

My code is as follows:

sub main()   

'''some more code'''

For j = InStr(1, stext, " ") To Len(stext)
        I开发者_运维知识库f IsNumeric(Mid(stext, j, 1)) Or IsAlpha(Mid(stext, j, 1)) Then
            letter1 = Mid(stext, j, Len(stext))
            Exit For
        End If
    Next j

'''some more code'''

end sub

As I walk through the macro, when it gets to this line:

If IsNumeric(Mid(stext, j, 1)) Or IsAlpha(Mid(stext, j, 1)) Then

it escapes the entire sub!

What am I doing wrong, and how do I resolve it?


This typically happens when you have an error. In this case, it could be an out of bounds error. You could have a space at the end of stext, which would cause this problem.


I think this might help.

ISALPHA, ISNUMERIC? - Microsoft Access / VBA Answers

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号