Returns a string or object consisting of the specified character repeated the specified number of times.
Public Shared Function StrDup( _ ByVal Number As Integer, _ ByVal Character As { Char | String } _ ) As String
-or-
Public Shared Function StrDup( _ ByVal Number As Integer, _ ByVal Character As Object _ ) As Object
Exception type | Error number | Condition |
---|---|---|
5 | Number < 0 or Character type is invalid. | |
5 | 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 myString As String aObject = "This is a String contained within an Object" myString = StrDup(5, "P") ' Returns "PPPPP" myString = StrDup(10, aString) ' Returns "WWWWWWWWWW" myString = StrDup(6, aObject) ' Returns "TTTTTT"
SPC Function |