Hello
Would like to Get or Display the Array Value of Splited(TextString)
with above code we know the following result
What i am interested in if i type the string "Jumps" then I should get FindArray(Result) or Array value as 4 . Hope i am making my statement clear.
The below returns Boolean True although IsInarray defined as Long
Will appreciate your valuable inputs
Thanks
NimishK
Would like to Get or Display the Array Value of Splited(TextString)
VBA Code:
Sub SplitWords()
Dim TextStrng As String
Dim Result() As String
TextStrng = "The Quick Brown Fox Jumps Over The Lazy Dog"
Result() = Split(TextStrng)
End Sub
Result(0) = "The"
Result(1) = "Quick"
Result(2) = "Brown"
Result(3) = "Fox"
Result(4) = "Jumps"
Result(5) = "Over"
Result(6) = "The"
Result(7) = "Lazy"
Result(8) = "Dog"
What i am interested in if i type the string "Jumps" then I should get FindArray(Result) or Array value as 4 . Hope i am making my statement clear.
The below returns Boolean True although IsInarray defined as Long
VBA Code:
Sub Test
Dim TextStrng As String
Dim Result() As String
TextStrng = "The Quick Brown Fox Jumps Over The Lazy Dog"
Result() = Split(TextStrng)
MsgBox (IsInArray("Jumps", Result) > -1)
End Sub
Function IsInArray(stringToBeFound As String, arr As Variant) As Long
Dim i As Long
IsInArray = -1
For i = LBound(arr) To UBound(arr)
If StrComp(stringToBeFound, arr(i), vbTextCompare) = 0 Then
IsInArray = i
Exit For
End If
Next i
End Function
Will appreciate your valuable inputs
Thanks
NimishK