Space
You might actually want to pad out a string with blank space. If so, the Space function is the one you want. In between the round brackets, you type a number. This number is how many space characters you want. Here's some code to illustrate this:
Dim FullName As String
FullName = "David Glimour"
MsgBox Len(FullName)
FullName = Space(5) & FullName
MsgBox Len(FullName)
The first message box display a value of 13, which is how many characters are in the name David Gilmour. The second message mob displays a value of 18, the 13 original characters, plus 5 added to the start of the name.
We could have added 5 blank spaces to the end of the name with this:
FullName = FullName & Space(5)
You might be confused about the use of the FullName
variable twice, here. But start after the equal sign and it will make sense. We have this after the equal sign:
FullName & Space(5)
This says, "Take whatever is in the variable called FullName and join 5 space characters to it." (The & symbol is used to join things together, remember. This is called concatenation.)
Once VBA has joined the text and the space, it needs to store it somewhere. Whatever is to the left of the equal sign is the place where it will be stored. To the left of the equal sign, we have the FullName
variable again. Whatever was previously in the variable will be replaced. It will be replaced by the value from the right of the equal sign, which was the name plus 5 characters.