Question : string extraction

I would like to extract the following from a string:

any numerals followed by the letter V or v:
#V
##V

not
###V

must igonre all characters after the V and ignore all characters or numerals before #V Or before ##V

Answer : string extraction

The function below returns the first such embedded number from a string.

(°v°)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
Function GetNumV(Text)
    Dim pos As Integer
    Do
        pos = InStr(pos + 1, Text, "V")
        If pos > 2 Then
            If Mid(Text, pos - 2, 2) Like "##" Then
                GetNumV = Val(Mid(Text, pos - 2, 2))
                Exit Function
            End If
        End If
        If pos > 1 Then
            If Mid(Text, pos - 1, 1) Like "#" Then
                GetNumV = Val(Mid(Text, pos - 1, 1))
                Exit Function
            End If
        End If
    Loop While pos
    GetNumV = Null
End Function
Random Solutions  
 
programming4us programming4us