VBA. How to find position of first digit in string

前端 未结 6 1228
陌清茗
陌清茗 2020-12-31 08:47

I have string \"ololo123\". I need get position of first digit - 1. How to set mask of search ?

6条回答
  •  庸人自扰
    2020-12-31 09:12

    Here is a lightweight and fast method that avoids regex/reference additions, thus helping with overhead and transportability should that be an advantage.

    Public Function GetNumLoc(xValue As String) As Integer
    
    For GetNumLoc = 1 To Len(xValue)
        If Mid(xValue, GetNumLoc, 1) Like "#" Then Exit Function
    Next
    
    GetNumLoc = 0
    
    End Function
    

提交回复
热议问题