开发者

Conditional In For-Loop Escapes Sub

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜