WorksheetFunction.ReplaceB Method

REPLACEB replaces part of a text string, based on the number of bytes you specify, with a different text string.

Namespace:  Microsoft.Office.Interop.Excel
Assembly:  Microsoft.Office.Interop.Excel (in Microsoft.Office.Interop.Excel.dll)

Syntax

'Declaration
Function ReplaceB ( _
    Arg1 As String, _
    Arg2 As Double, _
    Arg3 As Double, _
    Arg4 As String _
) As String
'Usage
Dim instance As WorksheetFunction
Dim Arg1 As String
Dim Arg2 As Double
Dim Arg3 As Double
Dim Arg4 As String
Dim returnValue As String

returnValue = instance.ReplaceB(Arg1, _
    Arg2, Arg3, Arg4)
string ReplaceB(
    string Arg1,
    double Arg2,
    double Arg3,
    string Arg4
)

Parameters

  • Arg1
    Type: System.String

    Old_text - text in which you want to replace some characters.

  • Arg2
    Type: System.Double

    Start_num - the position of the character in old_text that you want to replace with new_text.

  • Arg3
    Type: System.Double

    Num_chars - the number of characters in old_text that you want REPLACE to replace with new_text.

  • Arg4
    Type: System.String

    New_text - the text that will replace characters in old_text.

Return Value

Type: System.String

Remarks

Important

Replace(String, Double, Double, String) is intended for use with languages that use the single-byte character set (SBCS), whereas ReplaceB is intended for use with languages that use the double-byte character set (DBCS). The default language setting on your computer affects the return value in the following way:

Replace(String, Double, Double, String) always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.

ReplaceB counts each double-byte character as 2 when you have enabled the editing of a language that supports DBCS and then set it as the default language. Otherwise, ReplaceB counts each character as 1.

The languages that support DBCS include Japanese, Chinese (Simplified), Chinese (Traditional), and Korean.

See Also

Reference

WorksheetFunction Interface

WorksheetFunction Members

Microsoft.Office.Interop.Excel Namespace