文字列:文字を指定数並べた文字列を返す(String 関数)
String 関数
【書式】
result = String ( number, character )
引数・戻り値
- number ・・・ 並べる文字の数を指定します。
- character ・・・ 文字コード(ASCII または シフトJIS)または文字列を指定し、文字コードの示す文字、もしくは文字列の先頭文字が、並べる対象の文字となります。
- result ・・・ character で指定された文字(文字コードの示す文字または文字列の先頭の文字)を number 個並べて作成した文字列(バリアント型)
引数 character に ASCII でもシフトJIS でもない無効な数値を指定すると、0 として処理されます。
引数 character に Null 値が含まれる場合は、Null 値を返します。
引数 number に Null 値が含まれる場合は、エラーとなります。
Space 関数 の使用例
サンプルVBAソース
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Sub Sample_String() Debug.Print String(5, "#") '##### Debug.Print String(8, "おはよう!") 'おおおおおおおお Debug.Print String(3, 35) '### Debug.Print String(7, 50) '2222222 Debug.Print String(10, 66) 'BBBBBBBBBB Debug.Print String(5, Null) 'Null End Sub |
実行結果
関連記事
-
-
ポイント単位の値に変換(CentimetersToPoints,InchesToPoints)
CentimetersToPoints メソッド センチメートル単位の値をポイン …
-
-
配列の要素数を取得する(UBound 関数・LBound 関数)
UBound 関数・LBound 関数 【書式】 result = UBound …
-
-
文字列:文字列の一部を別の文字列で置換(Replace 関数)
Replace 関数の使い方 【書式】 result = Replace ( s …
-
-
色の設定(ColorIndex プロパティ・Colors プロパティ)
ColorIndex プロパティ ColorIndex プロパティは、指定したオ …
-
-
データをクリアする(ClearContents メソッド)
ClearContents メソッド 対象がセル範囲(Range オブジェクト) …
-
-
Array 関数(バリアント型の配列を作成)
Array 関数の使い方 【書式】 myArray = Array ( elem …
-
-
指定した値を8進数で表記した文字列に変換する(Oct 関数)
Oct 関数 の使い方 【書式】 result = Oct ( expressi …
-
-
Join 関数(配列の要素を結合)
Join 関数 1次元配列の各要素を指定した区切り文字で連結します。 【書式】 …
-
-
オブジェクトの書式をクリアする(ClearFormats メソッド)
ClearFormats メソッド 対象となるオブジェクトの書式(スタイル)を初 …
-
-
ある数値が、複数の範囲のどの範囲に含まれるかを示す文字列を返す(Partition 関数)
Partition 関数 の使い方 Partition 関数は、ある数値が、区切 …
