Len() returns the number of characters in a string. Spaces are characters too, even when consecutive spaces are collapsed visually by normal HTML rendering.
Dim my_string
my_string="Welcome to Plus2net.com"
Response.Write my_string
Response.Write "<br>Length of this string = " & Len(my_string)
Welcome to Plus2net.com
Length of this string = 23
my_string=" Welcome to Plus2net.com"
Response.Write my_string
Response.Write "<br>Length of this string = " & Len(my_string)
Welcome to Plus2net.com
Length of this string = 26
The browser collapses consecutive spaces in normal HTML, but Len() still counts the three leading spaces.
my_string="Welcome to Plus2net.com"
Response.Write my_string
Response.Write "<br>Length of this string = " & Len(my_string)
Response.Write "<br>Byte-oriented length = " & LenB(my_string)
Welcome to Plus2net.com
Length of this string = 23
Byte-oriented length = 46
LenB() is byte-oriented and may differ from Len() for Unicode/DBCS data. Do not treat a fixed 2-bytes-per-character result as a portable rule for storage, network payload size, or UTF-8 length.Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.