I would like to compare if a string has all the characters of another string.
Example:
String 1 Hejslclo
String 2 Hello
True string 2 has all the characters of string one.
I have turned string 1 into an array and I think there should be a loop to check using Instr
My first attempt at this:
Sub StringintoArray()
Dim Temp As String
Dim MyString As String
Dim String2 As String
MyString = "Heaslsflo"
String2 = "Hello"
Temp = StrConv(MyString, vbUnicode)
Temp = Left(Temp, Len(Temp) - 1)
aLetter = Split(Temp, Chr(0))
'Dim StartRow As Integer
Dim i As Integer
For i = 0 To L(Temp)
If InStr(i, String2, aLetter(I)) <> 0 Then
MsgBox ("Yes")
Else
MsgBox ("No")
End If
Next i
End Sub
False, by the way you explained. String 2 does not have all the characters of String 1. That's actually the other way around. String 1 has all characters of String 2. String 2 is "contained" in String 1...This is one of the issues you might find when coding for yourself and that you need to decide. You want to compare String 1 against String 2 or String 2 against String 1? Depending on what you want, the string that will become an array will change. You are in the right path though, on creating one as an array and loop through the other with InStr.