String, String$ (functions)

Syntax

String[$](number,[CharCode | text$])

Description

Returns a string of length number consisting of a repetition of the specified filler character.

Comments

String$ returns a String, whereas String returns a String variant.

These functions take the following parameters:

 

Parameter

Description

 

number

Integer specifying the number of repetitions.

 

CharCode

Integer specifying the character code to be used as the filler character. If CharCode is greater than 255 (the largest character value), then the Basic Control Engine converts it to a valid character using the following formula:

CharCode Mod 256

 

text$

Any String expression, the first character of which is used as the filler character.

Example

This example uses the String function to create a line of "=" signs the length of another string and then displays the character string underlined with the generated string.

Const crlf = Chr$(13) + Chr$(10)

Sub Main()
  a$ = "This string will appear underlined."
  b$ = String(Len(a$),"_")
  MsgBox a$ & crlf & b$
End Sub

See Also

Space, Space$ (functions).

More information

S