Hi all, i have string "super" May i know is there a function in vb where i can repeat the string like using the below code and return "supersupersuper" Thanks :)
Code:StrDup(3, "super")
Printable View
Hi all, i have string "super" May i know is there a function in vb where i can repeat the string like using the below code and return "supersupersuper" Thanks :)
Code:StrDup(3, "super")
here's a vb2008+ extension to the string class:
vb Code:
Module extensions <System.Runtime.CompilerServices.Extension()> _ Public Function strDup(ByVal instance As String, ByVal number As Integer) As String Dim returnString As String = "" For x As Integer = 1 To number returnString &= instance Next Return returnString End Function End Module
here's how to use it:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("super".strDup(3)) End Sub