Question: The following code is to add the font tag to every character, but it don't work

```
Function AddFontTag (counter)
    Do While Len (counter) < 7
        newStr = newStr & "<font>" & Left (counter, i) & "</font>"
        i = i + 1
    Loop
    AddFontTag = newStr
End Function

```

Because i'm not skilled in classic asp, such as variable scope, syntax. Does anyone know what's the problems of the above code?

thanks

Answer: 
Your `do..while` loop is an infinite loop - assuming `counter` is a string variable, its length never changes so if `Len(counter)` is less than `7` upon entering the function, it'll always stay less than `7` so your function never exits.

Your `newStr` variable is undefined - this works in VBScript but it's really bad practice and it's a source of countless errors. Is it a global variable or is it supposed to be a local? (It looks like a local.)
I'm not sure of how your 7 character limit applies, but for a general approach the following will do what you need for any length string:

```vb
function AddFontTag(byval str)
    AddFontTag = Empty
    do while len(str) <> 0
        ' get next character
        dim c: c = left(str, 1)
        ' reduce original string
        str = right(str, len(str) - 1)
        ' build up output string
        AddFontTag = AddFontTag & "<font>" & c & "</font>"
    loop
end function

```

The example

```
dim test: test = AddFontTag("a test")
Response.Write test

```

will give you

> 
> <font>a</font><font> </font><font>t</font><font>e</font><font>s</font><font>t</font>
> 
> 
> 

If you only want to apply this to strings of length less than 7 you can add

```
if len(str) > 6 then
    exit function
end if

```

before the while loop or

```
str = left(str, 6)

```

if you just want to apply it to the first 6 characters of any length string