Repeat a string: Difference between revisions

Content added Content deleted
m (→‎{{header|Visual Basic}}: Suppress space)
Line 2,196: Line 2,196:


An alternative method:
An alternative method:
<lang vb>Public Function StrRepeat(sText As String, n As Integer) As String
<lang vb>
Public Function StrRepeat(sText As String, n As Integer) As String
StrRepeat = Replace(String(n, "*"), "*", sText)
StrRepeat = Replace(String(n, "*"), "*", sText)
End Function
End Function</lang>
</lang>


<br>'''Repeat a character'''<br>
<br>'''Repeat a character'''<br>
<lang VBA>
<lang VBA>Debug.Print String(5, "x")</lang>
Debug.Print String(5, "x")
</lang>
{{out}}
{{out}}
<pre>xxxxx</pre>
<pre>xxxxx</pre>