Редагувати

Поділитися через


Strings.StrDup Method

Definition

Returns a string or object consisting of the specified character repeated the specified number of times.

Overloads

StrDup(Int32, Char)

Returns a string or object consisting of the specified character repeated the specified number of times.

StrDup(Int32, Object)

Returns a string or object consisting of the specified character repeated the specified number of times.

StrDup(Int32, String)

Returns a string or object consisting of the specified character repeated the specified number of times.

StrDup(Int32, Char)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

Returns a string or object consisting of the specified character repeated the specified number of times.

public:
 static System::String ^ StrDup(int Number, char Character);
public static string StrDup (int Number, char Character);
static member StrDup : int * char -> string
Public Function StrDup (Number As Integer, Character As Char) As String

Parameters

Number
Int32

Required. Integer expression. The length to the string to be returned.

Character
Char

Required. Any valid Char, String, or Object expression. Only the first character of the expression will be used. If Character is of type Object, it must contain either a Char or a String value.

Returns

A string or object consisting of the specified character repeated the specified number of times.

Exceptions

Number is less than 0 or Character type is not valid.

Character is Nothing.

Examples

This example uses the StrDup function to return a string of duplicated characters.

Dim aString As String = "Wow! What a string!"
Dim aObject As New Object
Dim testString As String
aObject = "This is a String contained within an Object"
' Returns "PPPPP"
testString = StrDup(5, "P")
' Returns "WWWWWWWWWW"
testString = StrDup(10, aString)
' Returns "TTTTTT"
testString = CStr(StrDup(6, aObject))

Remarks

This function returns a String made up of repeated characters. The character that makes up the string is the first character in the Character argument, and it is duplicated Number number of times.

See also

Applies to

StrDup(Int32, Object)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

Returns a string or object consisting of the specified character repeated the specified number of times.

public:
 static System::Object ^ StrDup(int Number, System::Object ^ Character);
public static object StrDup (int Number, object Character);
static member StrDup : int * obj -> obj
Public Function StrDup (Number As Integer, Character As Object) As Object

Parameters

Number
Int32

Required. Integer expression. The length to the string to be returned.

Character
Object

Required. Any valid Char, String, or Object expression. Only the first character of the expression will be used. If Character is of type Object, it must contain either a Char or a String value.

Returns

A string or object consisting of the specified character repeated the specified number of times.

Exceptions

Number is less than 0 or Character type is not valid.

Character is Nothing.

Examples

This example uses the StrDup function to return a string of duplicated characters.

Dim aString As String = "Wow! What a string!"
Dim aObject As New Object
Dim testString As String
aObject = "This is a String contained within an Object"
' Returns "PPPPP"
testString = StrDup(5, "P")
' Returns "WWWWWWWWWW"
testString = StrDup(10, aString)
' Returns "TTTTTT"
testString = CStr(StrDup(6, aObject))

Remarks

This function returns a String made up of repeated characters. The character that makes up the string is the first character in the Character argument, and it is duplicated Number number of times.

See also

Applies to

StrDup(Int32, String)

Source:
Strings.vb
Source:
Strings.vb
Source:
Strings.vb

Returns a string or object consisting of the specified character repeated the specified number of times.

public:
 static System::String ^ StrDup(int Number, System::String ^ Character);
public static string StrDup (int Number, string Character);
static member StrDup : int * string -> string
Public Function StrDup (Number As Integer, Character As String) As String

Parameters

Number
Int32

Required. Integer expression. The length to the string to be returned.

Character
String

Required. Any valid Char, String, or Object expression. Only the first character of the expression will be used. If Character is of type Object, it must contain either a Char or a String value.

Returns

A string or object consisting of the specified character repeated the specified number of times.

Exceptions

Number is less than 0 or Character type is not valid.

Character is Nothing.

Examples

This example uses the StrDup function to return a string of duplicated characters.

Dim aString As String = "Wow! What a string!"
Dim aObject As New Object
Dim testString As String
aObject = "This is a String contained within an Object"
' Returns "PPPPP"
testString = StrDup(5, "P")
' Returns "WWWWWWWWWW"
testString = StrDup(10, aString)
' Returns "TTTTTT"
testString = CStr(StrDup(6, aObject))

Remarks

This function returns a String made up of repeated characters. The character that makes up the string is the first character in the Character argument, and it is duplicated Number number of times.

See also

Applies to