Make your own free website on Tripod.com

The Space Function

 


The Space function is very closely linked to the Tab function. However, there is a
minor difference. While Tab (n) means the item is placed n spaces from the left
border of the screen, the Space function specifies the number of spaces between two
consecutive items. For example, the procedure


Private Sub Form_Activate ()
Print "Visual"; Space (10); "Basic"
End Sub
means that the words Visual and Basic will be separated by 10 spaces.

The example here compute a multiplication table  using the Space function. The output is shown in the diagram on the right. Notice that the alignments of the columns are totally off. Therefore, it is normally better touse the Tab function rather than the Spaces function if we want a uniform display ofthe items in a table.

Private Sub Form_Activate ()
For x = 1 To 10
Print "2" & "x" & Str(x) & "=" & Space (2); Str(2 * x) _
; Space (6); "3" & "x" & Str(x) & "=" & Space (2); Str (3 * x) _
; Space (6); "4" & "x" & Str(x) & "=" & Space (2); Str (4 * x) _
; Space (6); "5" & "x" & Str(x) & "=" & Space (2); Str(5 * x) _
; Space (6); "6" & "x" & Str(x) & "=" & Space (2); Str(6 * x) _
; Space (6); "7" & "x" & Str(x) & "=" & Space (2); Str(7 * x) _
; Space (6); "8" & "x" & Str(x) & "=" & Space (2); Str(8 * x) _


; Space (6); "9" & "x" & Str(x) & "=" & Space (2); Str(9 * x) _
; Space (6); "10" & "x" & Str(x) & "=" & Space (2); Str(10 * x) _
Next x
End Sub
 


 


 

 

 

 


 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

[Back to VB Today]