User Tools

Site Tools


vba:functions:printf:index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vba:functions:printf:index [24.10.2016 09:00:33]
yaslaw
vba:functions:printf:index [13.02.2020 08:51:20] (current)
yaslaw
Line 1: Line 1:
- ​%tH:​%tM:​%tS<​const>​ +<​const>​ 
-    version=2.4.0 +    version=2.7.1 
-    vdate=14.10.2016+    vdate=13.02.2020
     fname=lib_printf.bas     fname=lib_printf.bas
     ns=%NAMESPACE%     ns=%NAMESPACE%
Line 70: Line 70:
   ***Typ** Mit einem Buchstaben wird definiert, um was für ein Datentyp es sich handelt   ***Typ** Mit einem Buchstaben wird definiert, um was für ein Datentyp es sich handelt
   ***//​Datum/​ZeitFormat//​** Wennd er Type T oder S ist, wird mit diesem Teil angegeben, was vom Datum angezeigt werden soll   ***//​Datum/​ZeitFormat//​** Wennd er Type T oder S ist, wird mit diesem Teil angegeben, was vom Datum angezeigt werden soll
 +  ***//​Maskierung//​** Wenn vor dem % ein \ steht, dann ist das %maskiert und der Pattern wird nicht geparst. Soll aber das \ als Textelement dienen, so muss dieses maskiert werden: \\%s
  
 === Typ === === Typ ===
Line 84: Line 85:
 == Text == == Text ==
 \\ **s** the argument is treated as and presented as a string. \\ **s** the argument is treated as and presented as a string.
 +\\ **q** the argument is treated as and presented as a string in sql-form: '​string'​
 \\ **x** the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters). \\ **x** the argument is treated as an integer and presented as a hexadecimal number (with lowercase letters).
 \\ **X** the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters). \\ **X** the argument is treated as an integer and presented as a hexadecimal number (with uppercase letters).
Line 136: Line 138:
 ==== Beispiel mit Reheinfolge ==== ==== Beispiel mit Reheinfolge ====
 <code vb> <code vb>
 +'​Mittels Positionszahl und $ kann angegeben werden, welcher Parameter gemeint ist. Es beginnt bei 1
 ? sPrintF("​%2$s wiegt %1$f Kilo", 76.5, "​Hans"​) ? sPrintF("​%2$s wiegt %1$f Kilo", 76.5, "​Hans"​)
 Hans wiegt 76.5 Kilo Hans wiegt 76.5 Kilo
Line 142: Line 145:
 Heute ist Heute und Morgen ist Morgen Heute ist Heute und Morgen ist Morgen
  
 +'​Mittels < kann angegeben werden, dass derselbe Parameter wir beim Pattern davor verwendet wird
 ? sPrintF("​%s ist %<s und %s ist %<​s",​ "​Heute",​ "​Morgen"​) ? sPrintF("​%s ist %<s und %s ist %<​s",​ "​Heute",​ "​Morgen"​)
 Heute ist Heute und Morgen ist Morgen Heute ist Heute und Morgen ist Morgen
Line 148: Line 152:
 Wir haben 10, ich wiederhole. Wir haben 10 Tage Zeit 20 Millionen zu finden Wir haben 10, ich wiederhole. Wir haben 10 Tage Zeit 20 Millionen zu finden
  
 +'​Dasselbe,​ jetzt jedoch zusätzlich mit Positionsangeben
 ? sPrintF("​%s,​ %<s, %<s! %3$s, %<s, %<s! %2$s, %<s, %<s! %s!", "​Ha",​ "​Ho",​ "​Hi",​ "​Yes"​) ? sPrintF("​%s,​ %<s, %<s! %3$s, %<s, %<s! %2$s, %<s, %<s! %s!", "​Ha",​ "​Ho",​ "​Hi",​ "​Yes"​)
 Ha, Ha, Ha! Hi, Hi, Hi! Ho, Ho, Ho! Yes! Ha, Ha, Ha! Hi, Hi, Hi! Ho, Ho, Ho! Yes!
Line 165: Line 170:
 <code vb> <code vb>
 '​Strings:​ '​Strings:​
-debug.print sprintf("​%1$s ​  ​%1$'#​6s ​  ​%1$-'#​6s ​  ​%1$.3s ​  ​%1$-.3s",​ "​abcd"​) +' ​  ​[Hochkomma][Zeichen][Länge] = String mit [Zeichen] als Prefix auf [Länge] erweitert 
-abcd   ##​abcd ​  ​abcd## ​  ​abc ​  bcd+' ​  ​[Minus][Hochkomma][Zeichen][Länge] = dito, jedoch wird hinten mit [Zeichen] aufgefüllt 
 +' ​  ​[Punkt][Länge] = Der String wird auf [Länge] beschnitten 
 +' ​  ​[Minus][Punkt][Länge] = dito, jedoch von hinten 
 +debug.print sprintf("​%1$s ​  ​%1$'#​6s ​  ​%1$-'#​6s ​  ​%1$.3s ​  ​%1$-.3s ​  %1$q", "​abcd"​) 
 +abcd   ##​abcd ​  ​abcd## ​  ​abc ​  ​bcd ​  '​abcd'​
  
 '​Nummern:​ '​Nummern:​
 'Float 'Float
-debug.print sprintf("​%1$f ​  ​%1$6f ​  ​%1$-.1f ​  ​%1$.3f ​  ​%1$d",​ 123.45) +' ​  ​[Länge] = Vor dem Dezimaltrennzeichen wird mit [Länge] 0 aufgefüllt. 
-123.45 ​  ​000123.45 ​  ​+123.5 ​  ​123.450 ​  123+' ​  ​[Punkt][Länge] = ANzahl Dezimalzeichen 
 +' ​  ​[Minus] = Das Vorzeichen wird mit immer angegeben 
 +debug.print sprintf("​%1$f ​  ​%1$6f ​  ​%1$-.1f ​  ​%1$.3f ​  %1$d   ​%<​-d", 123.45) 
 +123.45 ​  ​000123.45 ​  ​+123.5 ​  ​123.450 ​  123   +123
  
 '​Integer '​Integer
Line 195: Line 207:
 <code vb>​printF_UserDefinedDateFormat(0) = "​HH.NN"​ <code vb>​printF_UserDefinedDateFormat(0) = "​HH.NN"​
 printF_UserDefinedDateFormat(1) = "d. MMMM YYYY" printF_UserDefinedDateFormat(1) = "d. MMMM YYYY"
-debug.print sPrintF("​%TU1 um %<TU0", now)+debug.print sPrintF("​%Tu1 um %<Tu0", now)
  
 21. Oktober 2016 um 11.34</​code>​ 21. Oktober 2016 um 11.34</​code>​
vba/functions/printf/index.1477292433.txt.gz · Last modified: 24.10.2016 09:00:33 by yaslaw