Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Programming Gambas from Zip/Formatting

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Formatting These examples may vary depending on the regional settings on your computer (for time, date and currency). Formatting Numbers Example: Label1.text = Format(123456.789, ",#.00") shows as 123,456.79 Format(123456.789) shows as if you used gb.Standard http://Gambaswiki.org/wiki/cat/constant Formatting Constants gb.StandardUses gb.GeneralNumber for formatting numbers and gb.GeneralDate for formatting dates and times.gb.GeneralNumberWrites a number with twelve decimal digits. Uses scientific format if its absolute value is lower than 10-4 (0.0001) or greater than 107 (1 million).gb.FixedEquivalent to "0.00"gb.PercentEquivalent to "###%"gb.ScientificWrite a number with its exponent (power of ten) and eighteen decimal digits. Symbols in the Format Strings Symbols other than these print as they appear. For example, $ prints as is. + Print the sign of the number.Format(Pi, "+#.###")+3.142- Print the sign of the number only if it is negative.Format(Pi, "-#.###")3.142# Print a digit only if necessary. One # before the decimal point is all that is needed. After the decimal point, as many #’s as you want decimal places.Format(123.456789, "#.###")123.4570 Always print a digit, padding with a zero if necessary.Format(24.5, "$#.00")$24.50. Print the decimal pointFormat(123.456, "#.0")123.5, Separate the thousandsFormat(1234567890, "#,") Format(1234567890, ",#")1,234,567,890% Multiply the number by 100 and print a percent sign.Format(0.25, "#%")25%E This is Scientific Notation, which is “Something-times-ten-to-the-power-of-something”. “E” means “times ten to the power of...” 1.2E+3 means "Start with 1.200, then move the decimal point three places to the right (get bigger x 1000) to become 1200." Negative numbers after the “E” mean move the decimal point to the left.Format(1234.5, "#.#E##") Format(0.1234, "#.#E##")1.2E+3 1.2E-1$The national currency symbol (according to the country as set on your computer)Format(-1234.56, "$,#.###")-$1,234.56$$The international currency symbol (according to the country as set on your computer)Format(-1234.56, "$$,#.###")-AUD 1,234.56( )Negative numbers represented with brackets, which is what finance people use.Format(-123.4, "($$,#.00)")(AUD 123.40) Formatting Dates Example: Format(Now, gb.Standard) shows as 10/07/2019 21:07:26 Formatting Constants gb.GeneralDate Write a date only if the date and time value has a date part, and write a time only if it has a date part. Writes nothing for a null date or a short time when there is no date, and writes the date and time for all other cases.Format(Now, gb.GeneralDate) is 10/07/2019 21:17:45gb.Standard Uses gb.GeneralNumber for formatting numbers and gb.GeneralDate for formatting dates and times.10/07/2019 21:20:45gb.LongDate Long date formatWednesday 10 July 2019gb.MediumDate Medium date format10 Jul 2019gb.ShortDate Short date format10/07/2019gb.LongTime Long time format21:22:35gb.MediumTime Medium time format09:23 PMgb.ShortTime Short time format21:23 Format String Symbols Label1.text = Format(Now, "dddd dd/mm/yyyy hh:nn:ss") shows as Tuesday 09/07/2019 20:45:13 yy The year in two digitsh The houryyyy The year in four digitshh The hour in two digits. m The monthn The minutes. mm The month in two digits. nn The minutes in two digitsmmm Abbreviated month s The secondsmmmm Full name of the month ss The seconds in two digitsd The day : The time separatordd The day in two digitsu A point and the milliseconds, if non-zeroddd Abbreviated weekdayuu A point and the milliseconds in three digits. dddd Full name of the weekday t The timezone alphabetic abbreviation/ The date separatortt The timezone in HHMM formatAM/PM The AM or PM symbol Formatting Currency For the symbols in a format string, see above (numbers). gb.Currency Uses the national currency symbol.Format(14.50, gb.Currency) shows as $ 14.5gb.International Uses the international currency symbol. Format(14.50, gb.International) shows as AUD 14.5 DataTypes OperatorPrecedence