文字列:文字列右から指定文字数取得(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 |
実行結果
関連記事
-
-
変数がNull 値かどうかをチェックする( IsNull 関数 )
IsNull 関数の使い方 【書式】 result = IsNull ( exp …
-
-
日付時刻:日付時刻データを計算( DateAdd 関数 )
DateAdd 関数(日付・時刻の値を加算・減算結果を取得) 【書式】 resu …
-
-
メッセージボックスを表示(MsgBox関数)
MsgBox関数 【書式】 result = MsgBox ( Prompt [ …
-
-
上付き文字・下付き文字(Superscript,Subscript)
上付き文字(Superscript プロパティ) Superscript プロパ …
-
-
Math 関数( Abs,Atn,Cos,Exp,Log,Rnd,Sgn,Sin,Sqr,Tan )
Abs 関数 【書式】 value = Abs ( number ) 【引数・戻 …
-
-
セルのデータを区切り文字で複数のセルに分割する(TextToColumns メソッド)
TextToColumns メソッド TextToColumns メソッドを使用 …
-
-
配列の要素数を取得する(UBound 関数・LBound 関数)
UBound 関数・LBound 関数 【書式】 result = UBound …
-
-
カレントフォルダの取得・設定(DefaultFilePath プロパティ)
DefaultFilePath プロパティ カレントフォルダとは、ブックを開いた …
-
-
CPU に制御を移す(DoEvents 関数)
DoEvents 関数 DoEvents 関数を実行すると、CPU に制御を移し …
-
-
Option Compare ステートメント
Option Compare ステートメントの使い方 【書式】 Option C …
