Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Strings.StrDup Method (Int32, String)

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

Namespace:  Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
public static string StrDup(
	int Number,
	string Character
)

Parameters

Number
Type: System.Int32

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

Character
Type: System.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.

Return Value

Type: System.String
Returns a string or object consisting of the specified character repeated the specified number of times.
ExceptionCondition
ArgumentException

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

ArgumentNullException

Character is Nothing.

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.

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))

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.