question

StuartCoutts avatar image
0 Votes"
StuartCoutts asked StuartCoutts commented

how to pad a number with leading zeros

In reference to the following line from your forum... how-to-pad-a-number-with-leading-zeros

fmt = New String("0"c, 5) + New String("#"c, digits) + ".##"

What do the 'c's do after the "0" and "#"?

I don't even know what to search for to learn more lol. It also doen;t seem to like other letters but if I debug.print or console.write with and without the c it doesn't appear to make a difference.

It's not a coding issue this is more of a I havn't got a clue if I should really include it or not in future code.

dotnet-visual-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PeterFleischer-3316 avatar image
0 Votes"
PeterFleischer-3316 answered StuartCoutts commented

HI Stuart,
see Constant and Literal Data Types (Visual Basic).

c is a suffix for a literal of type System.Char. So

 Dim foo As Char = "x"c

will compile (when Option Strict is set to either On or Off). Without the c, it would be interpreted as a string.



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Many thanks... thats great!

0 Votes 0 ·