Simple Question

thhynes

Member
Joined
Dec 16, 2004
Messages
7
Location
Hartford, CT
Programming Experience
Beginner
Okay...
my notes from the class instructor are okay at best

the code givin is

textbox = variable.tostring ("D")

I am trying to get a constant value that has been declared
and to display that value in a text box as described above but I keep getting this error

An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Format specifier was invalid.

Whats going on?
Thanks!
Tom
 
Well, if your variable is not a date datatype then you can't format it in this way ... there are other ways how to format the thing :D
say you want to format it to long date ("D" stands for long and "d" stands for short date format) ... you can try somethign like this
VB.NET:
[COLOR=blue]Dim [/COLOR]variable [COLOR=blue]as[/COLOR] date = [COLOR=blue]Date[/COLOR].now [COLOR=darkgreen]'if variable is i.e. string the code below will throw a warn[/COLOR]
textbox = variable.tostring ("D") [COLOR=darkgreen]'this will return monday october 12th 2005[/COLOR]

HTH
Regards ;)
 
Back
Top