VBA – Len

  • Post author:
  • Post category:VBA
  • Post comments:0 Comments
Len function

The Len function returns the length of the given input string including the blank spaces.

Syntax

Len(String)

Example

Add a button and add the following function.

Private Sub Constant_demo_Click()
   Dim var1 as Variant
   Dim var2 as Variant
   
   var1 ="Microsoft VBScript"
   msgbox("Length of var1 is : " & Len(var1))
  
   var2 =       "       Microsoft VBScript           "
   msgbox ("Length of var2 is : " & Len(var2))
End Sub

When you execute the above function, it produces the following output.

Length of var1 is : 18
Length of var2 is : 36

Previous Page:-Click Here

Leave a Reply