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: 
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
your codes is looping without a condition to EXIT the looping.
try this... hope it helps.

```
Function AddFontTag (counter)
dim i,newStr,max
max=7
    Do While Len (counter) < max
        newStr = newStr & "<font>" & Left (counter, i) & "-" & "</font>"
        i = i + 1
        if i = max-1 then exit Do
    Loop
    AddFontTag = newStr
End Function
'to check the results
response.write AddFontTag ("params")

```

you will get
 `<font>-</font><font>p-</font><font>pa-</font><font>par-</font><font>para-</font><font>param-</font>`