For i = LBound(StrArray) to UBound(StrArray)
If InStr(StrArray(i), "&#") = 1 Then
StrOutput = StrOutput + ChrW(Right(StrArray(i),Len(StrArray(i))-2))
Else
StrOutput = Left(StrArray(i), InStr(StrArray(i),"&#") - 1)
End If
Next
[/code]
Modified into this is ok,But that's not what I want results
[code]dim StrInput, StrOutput, StrArray, i, TmpStr
For i = LBound(StrArray) to UBound(StrArray)
If InStr(StrArray(i), "&#") = 1 Then
StrOutput = StrOutput + ChrW(Right(StrArray(i),Len(StrArray(i))-2))
Else
StrOutput = Left(StrArray(i), InStr(StrArray(i),"&#"))
End If
Next[/code]
You're not handling the case where the string doesn't contain "&#", which means InStr is returning 0 (and you're then calling Left with -1 as the parameter).
Try something like the following:
[code]Dim StrInput, StrOutput, StrArray, i, TmpStr
For i = LBound(StrArray) To UBound(StrArray)
If InStr(StrArray(i), "&#") = 1 Then
StrOutput = StrOutput + ChrW(Right(StrArray(i),Len(StrArray(i))-2))
ElseIf InStr(StrArray(i), "&#") > 1 Then
StrOutput = Left(StrArray(i), InStr(StrArray(i),"&#") - 1)
Else
StrOutput = StrOutput + strArray(i)
End If
Next[/code]
[quote="jon"]You're not handling the case where the string doesn't contain "&#", which means InStr is returning 0 (and you're then calling Left with -1 as the parameter).
Try something like the following:
[code]Dim StrInput, StrOutput, StrArray, i, TmpStr
For i = LBound(StrArray) To UBound(StrArray)
If InStr(StrArray(i), "&#") = 1 Then
StrOutput = StrOutput + ChrW(Right(StrArray(i),Len(StrArray(i))-2))
ElseIf InStr(StrArray(i), "&#") > 1 Then
StrOutput = Left(StrArray(i), InStr(StrArray(i),"&#") - 1)
Else
StrOutput = StrOutput + strArray(i)
End If
Next[/code][/quote]