StrDup Function
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 |
|---|---|---|
|
Number is less than 0 or Character type is not valid. |
||
|
Character is Nothing. |
See the "Error number" column if you are upgrading Visual Basic 6.0 applications that use unstructured error handling. (You can compare the error number against the Number Property (Err Object).) However, when possible, you should consider replacing such error control with Structured Exception Handling Overview for Visual Basic.
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))
Namespace: Microsoft.VisualBasic
Module: Strings
Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)