Imports System
Class PadString
Public Shared Sub Main(ByVal args As String())
Dim str As String = "VB.NET"
Dim totalLength As Integer = 11
Dim padChar As Char = "*"c
Dim padded As String = padString(str, totalLength, padChar)
Console.WriteLine("Padded string: " & padded)
End Sub
Private Shared Function padString(ByVal str As String, ByVal totalLength As Integer, ByVal padChar As Char) As String
Dim paddingLeft As Integer = (totalLength - str.Length) / 2
Dim padded As String = str.PadLeft(paddingLeft + str.Length).PadRight(totalLength)
Return padded.Replace(" "c, padChar)
End Function
End Class
' run:
'
' Padded string: **VB.NET***
'