Code Snippet "VBA allgemein"
Holt die erste Ganzzahl aus einem String
Public Function getFirstLongFromString(inputstring As String) As Long
Dim number As String
number = ""
Dim counter As Integer
Dim result As Long
result = 0
Dim numberStarted As Boolean
numberStarted = False
For counter = 1 To Len(inputstring)
If IsNumeric(Mid(inputstring, counter, 1)) Then
number = number & Mid(inputstring, counter, 1)
numberStarted = True
Else
If numberStarted Then
Exit For
End If
End If
Next
If number <> "" Then
result = CLng(number)
End If
getFirstLongFromString = result
End Function