Mark__C
09-25-2002, 01:30 AM
Here's a challenge for you all. Well, really just something for me, but I'm too lazy to do it on my own and I figured I'd give you all a chance to do it for me :). Anyway, I need something to search a string for all the occurences of the face emote, i.e. "':' and ')'". Then to replace it with the picture of the smiley that is included with Y!Messenger. I already have the function to replace it with the smiley picture, so I just want the function to replace all the occurrences with the picture.
Here's what I got so far (It only searches for one occurence of the smile emote though).
Dim aStr as String, aStr2 as String, aStr3 as String
Dim IntRead as Integer
StrText = "Happy :) Guy" + vbCrlf
Select Case True
Case InStr(1, StrText, ":" + Chr(41))
aStr = StdPicAsRTF(frmLobby.Smile)
IntRead = InStr(1, StrText, ":" + Chr(41))
aStr2 = Left(StrText, IntRead - 1)
aStr3 = Mid(StrText, IntRead + 2, Len(StrText))
StrText = aStr3
Case InStr(1, StrText, ":" + Chr(40))
aStr = StdPicAsRTF(frmLobby.Frown)
IntRead = InStr(1, StrText, ":" + Chr(40))
aStr2 = Left(StrText, IntRead - 1)
aStr3 = Mid(StrText, IntRead + 2, Len(StrText))
StrText = aStr3
Case Else
Output.SelStart = Len(Output.Text)
Output.SelRTF = StrText
Exit Sub
End Select
Output.SelStart = Len(Output.Text)
Output.SelRTF = aStr2 'adds substring before the ':)'
Output.SelRTF = aStr 'adds the Picture
Output.SelRTF = aStr3 'adds substring after ':)'
That's it. Good luck all and thanks!
Here's what I got so far (It only searches for one occurence of the smile emote though).
Dim aStr as String, aStr2 as String, aStr3 as String
Dim IntRead as Integer
StrText = "Happy :) Guy" + vbCrlf
Select Case True
Case InStr(1, StrText, ":" + Chr(41))
aStr = StdPicAsRTF(frmLobby.Smile)
IntRead = InStr(1, StrText, ":" + Chr(41))
aStr2 = Left(StrText, IntRead - 1)
aStr3 = Mid(StrText, IntRead + 2, Len(StrText))
StrText = aStr3
Case InStr(1, StrText, ":" + Chr(40))
aStr = StdPicAsRTF(frmLobby.Frown)
IntRead = InStr(1, StrText, ":" + Chr(40))
aStr2 = Left(StrText, IntRead - 1)
aStr3 = Mid(StrText, IntRead + 2, Len(StrText))
StrText = aStr3
Case Else
Output.SelStart = Len(Output.Text)
Output.SelRTF = StrText
Exit Sub
End Select
Output.SelStart = Len(Output.Text)
Output.SelRTF = aStr2 'adds substring before the ':)'
Output.SelRTF = aStr 'adds the Picture
Output.SelRTF = aStr3 'adds substring after ':)'
That's it. Good luck all and thanks!