Home All Groups Group Topic Archive Search About

Newbie: Year( ) function doesnt work !

Author
10 Oct 2005 3:15 AM
smith
Hi,
this is very weird!!
Neither Year(myDate) nor myDate.Year work!!

I have VB 6 with all latest updates as far as I know.

I Used this, taken straight from MSDN:

Dim MyDate, MyYear
MyDate = #10/19/1962#         ' Assign a date.
MyYear = Year(MyDate)         ' MyYear contains 1962
MsgBox (MyYear)

And it complains! BTW I typed the Y as capital and VB makes it a small .

However, when i type: VBA.Year(MyDate) I get the correct answer .
Also .year doesnt work : Mydate.year also complains.

Some sort of DLL I have to add ??

I could keep using VBA. as a prefix but its annoying and i want to
understand whats happening.

Thanx for any help in advance!

-steve

Author
10 Oct 2005 3:26 AM
Michael Cole
smith wrote:
Show quoteHide quote
> Hi,
> this is very weird!!
> Neither Year(myDate) nor myDate.Year work!!
>
> I have VB 6 with all latest updates as far as I know.
>
> I Used this, taken straight from MSDN:
>
> Dim MyDate, MyYear
> MyDate = #10/19/1962#         ' Assign a date.
> MyYear = Year(MyDate)         ' MyYear contains 1962
> MsgBox (MyYear)
>
> And it complains! BTW I typed the Y as capital and VB makes it a
> small .
>
> However, when i type: VBA.Year(MyDate) I get the correct answer .

So check within your code what you have named, "year".  Perhaps a variable
somewhere...

--
Regards,

Michael Cole
Author
10 Oct 2005 3:36 AM
smith
I am embarassed......!!!!! :(

Thank you for your help!


Show quoteHide quote
"Michael Cole" <no***@hansen.com> wrote in message
news:O81TjpUzFHA.3312@TK2MSFTNGP09.phx.gbl...
> smith wrote:
>> Hi,
>> this is very weird!!
>> Neither Year(myDate) nor myDate.Year work!!
>>
>> I have VB 6 with all latest updates as far as I know.
>>
>> I Used this, taken straight from MSDN:
>>
>> Dim MyDate, MyYear
>> MyDate = #10/19/1962#         ' Assign a date.
>> MyYear = Year(MyDate)         ' MyYear contains 1962
>> MsgBox (MyYear)
>>
>> And it complains! BTW I typed the Y as capital and VB makes it a
>> small .
>>
>> However, when i type: VBA.Year(MyDate) I get the correct answer .
>
> So check within your code what you have named, "year".  Perhaps a variable
> somewhere...
>
> --
> Regards,
>
> Michael Cole
>
>
Author
10 Oct 2005 4:27 AM
Michael Cole
smith wrote:
> I am embarassed......!!!!! :(

Don't worry, you are not alone.
One of the best I heard was someone calling a variable, "mID", which of
course meant that the Mid function didn't work.  Most of us would have done
something like that at some time in our life.

Show quoteHide quote
>
> Thank you for your help!
>
>
> "Michael Cole" <no***@hansen.com> wrote in message
> news:O81TjpUzFHA.3312@TK2MSFTNGP09.phx.gbl...
>> smith wrote:
>>> Hi,
>>> this is very weird!!
>>> Neither Year(myDate) nor myDate.Year work!!
>>>
>>> I have VB 6 with all latest updates as far as I know.
>>>
>>> I Used this, taken straight from MSDN:
>>>
>>> Dim MyDate, MyYear
>>> MyDate = #10/19/1962#         ' Assign a date.
>>> MyYear = Year(MyDate)         ' MyYear contains 1962
>>> MsgBox (MyYear)
>>>
>>> And it complains! BTW I typed the Y as capital and VB makes it a
>>> small .
>>>
>>> However, when i type: VBA.Year(MyDate) I get the correct answer .
>>
>> So check within your code what you have named, "year".  Perhaps a
>> variable somewhere...
>>
>> --
>> Regards,
>>
>> Michael Cole

--
Regards,

Michael Cole
Author
10 Oct 2005 6:49 AM
Lorin
Think that is bad.
I like to name my variables with a prefix indicating type.
So my string variable for the top of something is sTop
And it does.

Show quoteHide quote
"Michael Cole" wrote:

> smith wrote:
> > I am embarassed......!!!!! :(
>
> Don't worry, you are not alone.
> One of the best I heard was someone calling a variable, "mID", which of
> course meant that the Mid function didn't work.  Most of us would have done
> something like that at some time in our life.
>
> >
> > Thank you for your help!
> >
> >
> > "Michael Cole" <no***@hansen.com> wrote in message
> > news:O81TjpUzFHA.3312@TK2MSFTNGP09.phx.gbl...
> >> smith wrote:
> >>> Hi,
> >>> this is very weird!!
> >>> Neither Year(myDate) nor myDate.Year work!!
> >>>
> >>> I have VB 6 with all latest updates as far as I know.
> >>>
> >>> I Used this, taken straight from MSDN:
> >>>
> >>> Dim MyDate, MyYear
> >>> MyDate = #10/19/1962#         ' Assign a date.
> >>> MyYear = Year(MyDate)         ' MyYear contains 1962
> >>> MsgBox (MyYear)
> >>>
> >>> And it complains! BTW I typed the Y as capital and VB makes it a
> >>> small .
> >>>
> >>> However, when i type: VBA.Year(MyDate) I get the correct answer .
> >>
> >> So check within your code what you have named, "year".  Perhaps a
> >> variable somewhere...
> >>
> >> --
> >> Regards,
> >>
> >> Michael Cole
>
> --
> Regards,
>
> Michael Cole
>
>
>
Author
10 Oct 2005 7:03 AM
Ralph
"Lorin" <Lo***@discussions.microsoft.com> wrote in message
news:2835F0B4-1F23-4176-B0A6-D2B1A07DA053@microsoft.com...
>
> Think that is bad.
> I like to name my variables with a prefix indicating type.
> So my string variable for the top of something is sTop
> And it does.
>

ROFL!

Thank you, thank you. I'm the clown that got burnt with "mID". At least in
your case the error showed up rather quickly.

<g>
-ralph



Show quoteHide quote
> "Michael Cole" wrote:
>
> > smith wrote:
> > > I am embarassed......!!!!! :(
> >
> > Don't worry, you are not alone.
> > One of the best I heard was someone calling a variable, "mID", which of
> > course meant that the Mid function didn't work.  Most of us would have
done
> > something like that at some time in our life.
> >
> > >
> > > Thank you for your help!
> > >
> > >
> > > "Michael Cole" <no***@hansen.com> wrote in message
> > > news:O81TjpUzFHA.3312@TK2MSFTNGP09.phx.gbl...
> > >> smith wrote:
> > >>> Hi,
> > >>> this is very weird!!
> > >>> Neither Year(myDate) nor myDate.Year work!!
> > >>>
> > >>> I have VB 6 with all latest updates as far as I know.
> > >>>
> > >>> I Used this, taken straight from MSDN:
> > >>>
> > >>> Dim MyDate, MyYear
> > >>> MyDate = #10/19/1962#         ' Assign a date.
> > >>> MyYear = Year(MyDate)         ' MyYear contains 1962
> > >>> MsgBox (MyYear)
> > >>>
> > >>> And it complains! BTW I typed the Y as capital and VB makes it a
> > >>> small .
> > >>>
> > >>> However, when i type: VBA.Year(MyDate) I get the correct answer .
> > >>
> > >> So check within your code what you have named, "year".  Perhaps a
> > >> variable somewhere...
> > >>
> > >> --
> > >> Regards,
> > >>
> > >> Michael Cole
> >
> > --
> > Regards,
> >
> > Michael Cole
> >
> >
> >