|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
formatting time and dateIs this the .net way?
Dim msgDate As Date = Now TextBox1.Text = Format(msgDate, "yyMMdd") 'I want year month day 060306 TextBox2.Text = Format(msgDate, "HHmmss") 'I want 13:23:58 I didn't think .net encourages functions like format(var, string) any more but I'm not sure what takes it's place. cj wrote:
> Is this the .net way? You might prefer> > Dim msgDate As Date = Now > TextBox1.Text = Format(msgDate, "yyMMdd") 'I want year month day 060306 > TextBox2.Text = Format(msgDate, "HHmmss") 'I want 13:23:58 > > I didn't think .net encourages functions like format(var, string) any > more but I'm not sure what takes it's place. TextBox1.Text = msgDate.ToString("yyMMdd") TextBox2.Text = msgDate.ToString("HH:mm:ss") I suppose it could be argued that using the Date[Time]'s own ToString is more 'the .net way'. "In general, if you want a string representation of an object, ask its ToString to do the job" being the principle at work. -- Larry Lard Replies to group please Yes, that is what I was looking for. I'd tried, well I thought I tried
that earlier but couldn't get it to work. Wasn't sure what I should be doing so I thought I'd ask. Thanks Larry. Oh, and I really don't prefer it but I'm trying to move forward with the ..net way of doing things. :) Lastly I see an error in my example. I wrote I wanted 13:23:58 but I really wanted 132358 so I'll just remove the colons. Larry Lard wrote: Show quoteHide quote > cj wrote: >> Is this the .net way? >> >> Dim msgDate As Date = Now >> TextBox1.Text = Format(msgDate, "yyMMdd") 'I want year month day 060306 >> TextBox2.Text = Format(msgDate, "HHmmss") 'I want 13:23:58 >> >> I didn't think .net encourages functions like format(var, string) any >> more but I'm not sure what takes it's place. > > You might prefer > > TextBox1.Text = msgDate.ToString("yyMMdd") > TextBox2.Text = msgDate.ToString("HH:mm:ss") > > I suppose it could be argued that using the Date[Time]'s own ToString > is more 'the .net way'. "In general, if you want a string > representation of an object, ask its ToString to do the job" being the > principle at work. > >
VSTO 2005 - Read Range from excel
Create application to extract data from excel sheet How can we mail some file without mentioning the SMTP server addre OOP / 3-Tier development questions VB.NET 2005 & XML Treeview population directly from MSAccess How to create a Service to Log Application Names writing custom event for minimise, restore and close buttons Re: "Visual Web Developer does not support creating Web sites on a Macros too slow ! |
|||||||||||||||||||||||