Day(date)

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi All,

I am fairly new to VB .Net 2003. I have been reading a book and doing some
of the exercises. I was practicing with labels and it was explaing how to
have info show in the label, so I was experimenting with some of the other
fuctions they show like month, time etc. In the Form Load Event I could get
like Label1.Text = Month(Now) it would return a 9 or i could get the current
time to display. The book also reference Day(date) and it would return a
1-31 based on the day. But when ever I try to put Label1.text = Day(now) it
gives me an error saying Day is not valid. So I guess I am confused whe the
others would work but not Day. I can put this same expression in an access
form and it works just fine.
Can some tell me why it does not work in VB.Net?

Thanks for the Help.

Jeff
 
¤ Hi All,
¤
¤ I am fairly new to VB .Net 2003. I have been reading a book and doing some
¤ of the exercises. I was practicing with labels and it was explaing how to
¤ have info show in the label, so I was experimenting with some of the other
¤ fuctions they show like month, time etc. In the Form Load Event I could get
¤ like Label1.Text = Month(Now) it would return a 9 or i could get the current
¤ time to display. The book also reference Day(date) and it would return a
¤ 1-31 based on the day. But when ever I try to put Label1.text = Day(now) it
¤ gives me an error saying Day is not valid. So I guess I am confused whe the
¤ others would work but not Day. I can put this same expression in an access
¤ form and it works just fine.
¤ Can some tell me why it does not work in VB.Net?

I would fully qualify the function with its namespace (or use Imports):

Microsoft.VisualBasic.DateAndTime.Day


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Paul Clement said:
¤ Hi All,
¤
¤ I am fairly new to VB .Net 2003. I have been reading a book and doing
some
¤ of the exercises. I was practicing with labels and it was explaing how
to
¤ have info show in the label, so I was experimenting with some of the
other
¤ fuctions they show like month, time etc. In the Form Load Event I could
get
¤ like Label1.Text = Month(Now) it would return a 9 or i could get the
current
¤ time to display. The book also reference Day(date) and it would return
a
¤ 1-31 based on the day. But when ever I try to put Label1.text =
Day(now) it
¤ gives me an error saying Day is not valid. So I guess I am confused whe
the
¤ others would work but not Day. I can put this same expression in an
access
¤ form and it works just fine.
¤ Can some tell me why it does not work in VB.Net?

I would fully qualify the function with its namespace (or use Imports):

Microsoft.VisualBasic.DateAndTime.Day


Paul
~~~~
Microsoft MVP (Visual Basic)

Paul,

So does this mean that I would type the statement like:

Label1.Text = Microsoft.VisualBasic.DateAndTime.Day(Now)

or replace (Now) with like a hard coded date (09/21/2005).

Thanks,

Jeff
 
¤
¤ ¤ >
¤ > ¤ Hi All,
¤ > ¤
¤ > ¤ I am fairly new to VB .Net 2003. I have been reading a book and doing
¤ > some
¤ > ¤ of the exercises. I was practicing with labels and it was explaing how
¤ > to
¤ > ¤ have info show in the label, so I was experimenting with some of the
¤ > other
¤ > ¤ fuctions they show like month, time etc. In the Form Load Event I could
¤ > get
¤ > ¤ like Label1.Text = Month(Now) it would return a 9 or i could get the
¤ > current
¤ > ¤ time to display. The book also reference Day(date) and it would return
¤ > a
¤ > ¤ 1-31 based on the day. But when ever I try to put Label1.text =
¤ > Day(now) it
¤ > ¤ gives me an error saying Day is not valid. So I guess I am confused whe
¤ > the
¤ > ¤ others would work but not Day. I can put this same expression in an
¤ > access
¤ > ¤ form and it works just fine.
¤ > ¤ Can some tell me why it does not work in VB.Net?
¤ >
¤ > I would fully qualify the function with its namespace (or use Imports):
¤ >
¤ > Microsoft.VisualBasic.DateAndTime.Day
¤ >
¤ >
¤ > Paul
¤ > ~~~~
¤ > Microsoft MVP (Visual Basic)
¤
¤ Paul,
¤
¤ So does this mean that I would type the statement like:
¤
¤ Label1.Text = Microsoft.VisualBasic.DateAndTime.Day(Now)
¤
¤ or replace (Now) with like a hard coded date (09/21/2005).
¤

You can use Now or anything else that will convert to a Date, that would include a hard-coded date.

You can also do the following:

'at the top of the module
Imports Microsoft.VisualBasic.DateAndTime

'in your procedure
Label1.Text = Day(Now)


Paul
~~~~
Microsoft MVP (Visual Basic)
 
Paul Clement said:
¤
message
¤ ¤ >
¤ > ¤ Hi All,
¤ > ¤
¤ > ¤ I am fairly new to VB .Net 2003. I have been reading a book and
doing
¤ > some
¤ > ¤ of the exercises. I was practicing with labels and it was explaing
how
¤ > to
¤ > ¤ have info show in the label, so I was experimenting with some of the
¤ > other
¤ > ¤ fuctions they show like month, time etc. In the Form Load Event I
could
¤ > get
¤ > ¤ like Label1.Text = Month(Now) it would return a 9 or i could get the
¤ > current
¤ > ¤ time to display. The book also reference Day(date) and it would
return
¤ > a
¤ > ¤ 1-31 based on the day. But when ever I try to put Label1.text =
¤ > Day(now) it
¤ > ¤ gives me an error saying Day is not valid. So I guess I am confused
whe
¤ > the
¤ > ¤ others would work but not Day. I can put this same expression in an
¤ > access
¤ > ¤ form and it works just fine.
¤ > ¤ Can some tell me why it does not work in VB.Net?
¤ >
¤ > I would fully qualify the function with its namespace (or use
Imports):
¤ >
¤ > Microsoft.VisualBasic.DateAndTime.Day
¤ >
¤ >
¤ > Paul
¤ > ~~~~
¤ > Microsoft MVP (Visual Basic)
¤
¤ Paul,
¤
¤ So does this mean that I would type the statement like:
¤
¤ Label1.Text = Microsoft.VisualBasic.DateAndTime.Day(Now)
¤
¤ or replace (Now) with like a hard coded date (09/21/2005).
¤

You can use Now or anything else that will convert to a Date, that would
include a hard-coded date.

You can also do the following:

'at the top of the module
Imports Microsoft.VisualBasic.DateAndTime

'in your procedure
Label1.Text = Day(Now)


Paul
~~~~
Microsoft MVP (Visual Basic)

Ok Gotcha,

Thanks for the help.

Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top