VBA – Space

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

The Space function fills a string with a specific number of spaces.

Syntax

space(number)

Parameter Description

Number − A required parameter. The number of spaces that we want to add to the given string.

Example

Private Sub Constant_demo_Click()
   Dim var1 as Variant
   
   var1 = "Microsoft"
   Dim var2 as Variant
   
   var2 = "VBScript"
   msgbox(var1 & Space(2)& var2)
End Sub

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

Microsoft VBScript

Previous Page:-Click Here

Leave a Reply