文字列:文字列右から指定文字数取得(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 |
実行結果
関連記事
-
-
カレントフォルダの取得・設定(DefaultFilePath プロパティ)
DefaultFilePath プロパティ カレントフォルダとは、ブックを開いた …
-
-
日付時刻:日付から曜日を取得( Weekday 関数、WeekdayName 関数 )
Weekday 関数(日付から曜日を表す数値を返す)の使い方 【書式】 week …
-
-
Math 関数( Abs,Atn,Cos,Exp,Log,Rnd,Sgn,Sin,Sqr,Tan )
Abs 関数 【書式】 value = Abs ( number ) 【引数・戻 …
-
-
ある数値が、複数の範囲のどの範囲に含まれるかを示す文字列を返す(Partition 関数)
Partition 関数 の使い方 Partition 関数は、ある数値が、区切 …
-
-
IME の現在の状態を取得します(IMEStatus 関数)
IMEStatus 関数の使い方 【書式】 result = IMEStatus …
-
-
取り消し線を設定する(Strikethrough プロパティ)
取り消し線を設定する(Strikethrough プロパティ) Striketh …
-
-
テキストファイル(UTF-8)を読み込み、書き出し(ADODB.Stream)
Stream オブジェクト ADO(ActiveX Database Objec …
-
-
変数のデータ型・宣言(Dim ステートメント)
変数の宣言 一般的な方法 【書式】 Dim varname [ As type, …
-
-
変数が配列かどうかをチェックする( IsArray 関数 )
IsArray 関数の使い方 【書式】 result = IsArray( va …
-
-
日付時刻:日付時刻データを計算( DateAdd 関数 )
DateAdd 関数(日付・時刻の値を加算・減算結果を取得) 【書式】 resu …
