|
Sample VB Formats (Floyd Jay Winters 9/2/03, 2/4/04, 10/19/06)
(You could enter TextBox1.Text in place of X)
TextBox1.Text = FormatCurrency(X) ‘ Defaults to two places TextBox2.Text = FormatNumber(X, 1) TextBox3.Text = FormatNumber(X, 3) ‘ Display 3 possible insignificant 0s TextBox4.Text = FormatPercent(X, 2) TextBox5.Text = Format(X, "$##,##0.00") TextBox6.Text = Format(X, "0.0%") TextBox7.Text = Format(Now(), "Long Date") TextBox8.Text = Format(Now(), "hh:mm tt") TextBox9.Text = Format(Now(), "MMM. dd, yyyy HH:mm:ss") ‘ 24 hour time lblToday.Text = FormatDateTime(Today, DateFormat.ShortDate) lblToday.Text = Format(Today.ToShortDateString) ‘ Type . and pick choice
= = = Dim datPayDate As Date datPayDate = CDate(txtDate.Text) txtDate.Text = Format(datPayDate, "MM-dd-yy")
= = = DateTimePicker1.Format = DateTimePickerFormat.Custom DateTimePicker1.CustomFormat = "MMM. dd, yyyy"
= = = Dim fmtStr As String = "{0, -15}{1, 6:N1}{2, 10:C2}" ' 0, 1, 2 = Print Zones, 15, 6, 10 = Zone Widths, - means left justify ' N1 = format as Number 1 place, C2 = format as Currency 2 places Dim LastName As String = "Fitzgerald" Dim Hours As Integer = 40 : Dim Rate As Decimal = 10 ListBox1.Items.Add(String.Format(fmtStr, LastName, Hours, Rate)) ' Output: Fitzgerald 40.0 $10.00
|