format number to show up with leading "0"  
Author Message
bw12117





PostPosted: Visual Basic Express Edition, format number to show up with leading "0" Top

How do I get a number to show up with a leading 0. Fox example I would like 8 to show up as 08 and 11 to continue to show up as 11, not 011.

I tried this but I'm missing something.

Dim monthformat As Double

monthformat = (Monthminusone - 1)

Format(monthformat, "00")

MessageBox.Show(monthformat)



Visual Studio Express Editions41  
 
 
Jan Hyde





PostPosted: Visual Basic Express Edition, format number to show up with leading "0" Top

Messagebox.show(Format(monthformat,"00"))
 
 
DMan1





PostPosted: Visual Basic Express Edition, format number to show up with leading "0" Top

MessageBox.Show(monthformat.ToString("00"))



 
 
Solitaire





PostPosted: Visual Basic Express Edition, format number to show up with leading "0" Top

Alternatively, you can save the formatted month number as a string:


Dim monthformat As Double, strmonth As String

strmonth = monthformat.ToString("00")

MessageBox.Show(strmonth)