StringBuilder method AppendFormat
Imports System
Imports System.Text
Public Class MainClass
Shared Sub Main()
Dim buffer As StringBuilder = New StringBuilder()
Dim string1, string2 As String
string1 = "This {0} costs: {1:C}." & vbCrLf
Dim objectArray As Object() = New Object(1) {}
objectArray(0) = "car"
objectArray(1) = 1234.56
buffer.AppendFormat(string1, objectArray)
string2 = "Number:{0:D3}. " & vbCrLf & _
"Number right aligned with spaces:{0, 4}." & vbCrLf & _
"Number left aligned with spaces:{0, -4}."
buffer.AppendFormat(string2, 5)
Console.WriteLine(buffer.ToString())
End Sub
End Class
Related examples in the same category