Dear All,
Thanks for a great forum!
I have a function ( below ) which I plan to use to weed out Unicode character from a string.
The query feeds the array a string and then I work with it as below.
I have commented out the For Each as I am still working with the first part of the function, in particular writing the strText to an array called letters
I am now getting an error though.
I do not know why it goes out of range as I have specified the length of the array to be the string length...
Any help with this would be greatly appreciated.
Thanks.
Thank you,
Kind regards
Triacona
Thanks for a great forum!
I have a function ( below ) which I plan to use to weed out Unicode character from a string.
The query feeds the array a string and then I work with it as below.
Code:
[COLOR=#204A87]Function[/color] ReplaceUniCode(strText [COLOR=#204A87]As String[/color])[COLOR=#204A87] As Variant[/color]
[COLOR=#4E9A06]' Replace % with the character you want to substitute.[/color]
[indent]
[COLOR=#204A87]Dim[/color] letters() [COLOR=#204A87]As String[/color]
[COLOR=#204A87]ReDim[/color] letters(Len(strText) - 1)
[COLOR=#204A87]Dim[/color] i [COLOR=#204A87]As Integer[/color]
[COLOR=#204A87]Dim[/color] ch [COLOR=#204A87]As Variant[/color]
[COLOR=#204A87]For[/color] i = 1 [COLOR=#204A87]To[/color] Len(strText)
letters(i - 1) = Mid$(strText, i, 1)
[COLOR=#204A87]Next[/color] i
[/indent]
[COLOR=#4E9A06][indent]
' For Each ch In letters
' If ch = vbUnicode Then
' ch = StrConv(ch, vbFromUnicode, 1)
' Else
' ch = ch
' End If
' Next ch
[/indent][/color]
ReplaceUniCode = letters
[COLOR=#204A87]End Function[/color]
I have commented out the For Each as I am still working with the first part of the function, in particular writing the strText to an array called letters
I am now getting an error though.
I have put a break in and go through the loop, but it seems to give the above error.error said:Subscript out of Range on:
letter(i - 1) = Subscript out of Range
I do not know why it goes out of range as I have specified the length of the array to be the string length...
Any help with this would be greatly appreciated.
Thanks.
Thank you,
Kind regards
Triacona