文字列:文字列右から指定文字数取得(Right 関数,RightB 関数)
Right 関数・RightB 関数 の使い方
result_right = Right ( string, length )
result_rightb = RightB ( string, length )
引数・戻り値
- string ・・・ 任意の文字列・文字列式を指定します。
- length ・・・ 取得する文字の長さ(0 以上の整数値)を指定します。
- result_right ・・・ 引数 string の右端から length文字分を取得した文字列(文字列型:String)。
- result_rightb ・・・ 引数 string の右端から lengthバイト分を取得した文字列(文字列型:String)。
引数 string が、Null 値 を含む場合は、Null 値 を返します
引数 length に、0 を指定した場合は、長さ 0 の文字列 (“”) を返します。また、string の文字数以上の値を指定した場合は、string 全体を返します。
Right 関数・RightB 関数 の使用例
サンプルVBAソース
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
Sub Sample_Right() Dim myStr As String myStr = "あいうえお。abc def,ghi!" Debug.Print Right(myStr, 16) '右から16文字取得 Debug.Print RightB(myStr, 16) '右から16バイト取得 Debug.Print Right(myStr, 2) '右から2文字取得 Debug.Print RightB(myStr, 2) '右から2バイト取得 Debug.Print Right(myStr, 40) '右から40文字取得(文字数以上を指定) Debug.Print RightB(myStr, 40) '右から40バイト取得(バイト数以上を指定) Debug.Print Right(myStr, 0) '右から0文字取得 Debug.Print RightB(myStr, 0) '右から0バイト取得 End Sub |
実行結果
関連記事
-
-
ポイント単位の値に変換(CentimetersToPoints,InchesToPoints)
CentimetersToPoints メソッド センチメートル単位の値をポイン …
-
-
Split 関数(文字列型の一次配列を作成)
Split 関数の使い方 【書式】 myArray = Split ( expr …
-
-
文字列:文字列を検索してその最初の文字位置を返す(InStr 関数,InStrB 関数)
InStr 関数・InStrB 関数の使い方 【書式】 result = { I …
-
-
コレクション(Collection)オブジェクト「連想配列」
コレクション(Collection)オブジェクトの使い方 【書式】 Dim my …
-
-
IME の現在の状態を取得します(IMEStatus 関数)
IMEStatus 関数の使い方 【書式】 result = IMEStatus …
-
-
日付時刻:現在の日付・時刻を取得・設定(Now、Date、Time)
現在の日付・時刻を取得・設定 現在の日付・時刻を取得(Now 関数、Date 関 …
-
-
Array 関数(バリアント型の配列を作成)
Array 関数の使い方 【書式】 myArray = Array ( elem …
-
-
引数が省略されたかどうかをチェックする( IsMissing 関数 )
IsMissing 関数の使い方 【書式】 result = IsMissing …
-
-
変数が数値型かどうかをチェックする( IsNumeric 関数 )
IsNumeric 関数の使い方 【書式】 result = IsNumeric …
-
-
日付時刻:年・月・日を取得(Year、Month、Day 関数)
日付から年・月・日を取得する関数 【書式】 date_year = Year ( …
