Space and String[$] Functions

Purpose

Creates a string consisting of a string expression or space repeated a specified number of spaces.

Syntax

$ = Space[$](m%)
$ = String[$](m%, a$)
$ = String[$](m%, n%)

m%, n%: integer expression
a$: string

Description

Each of these functions create a string composed of another string repeated a certain number of times: with Space(m%), the result is a string of spaces m% characters long; with String(m%,a$) a string composed of a$ repeated m% times; and String(m%, n%) results in a string of length m% made up of Chr(n%).

Example

Debug.Show

Local b$ = "This is", c$ = "GFA"

Trace b$ & Space(10) & c$       // In both expressions

Trace String$(10, 65)           // the '$ on the end

Trace String(5, c$)             // is optional.

Known Issues

If the value of m% in either the Space or String function is zero or negative, an 'Access-Violation Exception' error can be thrown (this error was fixed in OCX version 2.342 build 1901).
[Reported by Jean-Marie Melanson. 17/02/17]

Remarks

Without the optional $ character the function still returns a String data type and not a Variant.

{Created by Sjouke Hamstra; Last updated: 27/01/2019 by James Gaite}