By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Day(date)

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Wed, 21 Sep 2005 12:41:50 -0500, "Jeff" <je*****@yahoo.com> wrote:

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)
Nov 21 '05 #2

P: n/a

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:jr********************************@4ax.com...
On Wed, 21 Sep 2005 12:41:50 -0500, "Jeff" <je*****@yahoo.com> wrote:

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
Nov 21 '05 #3

P: n/a
Label1.Text = DateTime.Now.Day

"Jeff" <je*****@yahoo.com> wrote in message
news:43**********@newspeer2.tds.net...
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

Nov 21 '05 #4

P: n/a
On Wed, 21 Sep 2005 14:14:19 -0500, "Jeff" <je*****@yahoo.com> wrote:


"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:jr********************************@4ax.com...
> On Wed, 21 Sep 2005 12:41:50 -0500, "Jeff" <je*****@yahoo.com> wrote:
>
> 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)
Nov 21 '05 #5

P: n/a

"Paul Clement" <Us***********************@swspectrum.com> wrote in message
news:v2********************************@4ax.com...
On Wed, 21 Sep 2005 14:14:19 -0500, "Jeff" <je*****@yahoo.com> wrote:


"Paul Clement" <Us***********************@swspectrum.com> wrote in
message
news:jr********************************@4ax.com...
> On Wed, 21 Sep 2005 12:41:50 -0500, "Jeff" <je*****@yahoo.com> wrote:
>
> 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
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.