Functions don't work in VB5? 
Author Message
 Functions don't work in VB5?

Hi all,

I am trying to use the Day, Month and Year functions to extract the
elements of the current date:

  x = Day(Date)
  y = Month(Date)
  z = Year(Date)

When I run these calls in the debug window, they return the right
answer. When I put them into my code, I get to these lines and it says
Compiler Error: Expected Array. Can anyone help me? I'm about to throw
VB5 in the garbage. But I'll save my ranting for another post.

        - Chris Kyarsgaard



Tue, 21 Sep 1999 03:00:00 GMT  
 Functions don't work in VB5?

Chris,

I tried: Command1.Caption = Year(Date)
and it works just fine in VB 4.0.
I guess I don't understand the problem either.

Quote:

> Hi all,

> I am trying to use the Day, Month and Year functions to extract the
> elements of the current date:

>   x = Day(Date)
>   y = Month(Date)
>   z = Year(Date)

> When I run these calls in the debug window, they return the right
> answer. When I put them into my code, I get to these lines and it says
> Compiler Error: Expected Array. Can anyone help me? I'm about to throw
> VB5 in the garbage. But I'll save my ranting for another post.

>         - Chris Kyarsgaard



Tue, 21 Sep 1999 03:00:00 GMT  
 Functions don't work in VB5?

Quote:

> Hi all,

> I am trying to use the Day, Month and Year functions to extract the
> elements of the current date:

>   x = Day(Date)
>   y = Month(Date)
>   z = Year(Date)

> When I run these calls in the debug window, they return the right
> answer. When I put them into my code, I get to these lines and it says
> Compiler Error: Expected Array. Can anyone help me? I'm about to throw
> VB5 in the garbage. But I'll save my ranting for another post.

>         - Chris Kyarsgaard

Nevermind. I've traced the problem back to my stupidity. I had declared
variables called Day, Month and Year. Duh. I humbly ask everyone's
forgiveness and promise I will look at my code before posting.

        - Chris Kyarsgaard



Tue, 21 Sep 1999 03:00:00 GMT  
 Functions don't work in VB5?

I tested your code in VB5 since I didn't have any problems with these
functions in previous versions. I didn't find anything wrong even when I
tried several possible variations with and without Option Explicit. I
suggest making sure that Option Explicit is declared in each form, module
and class file. I need a larger sample of your code to examine in order to
resolve the problem.

--
Chris Haltiner
Decision Consultants, Inc.



Quote:
> I am trying to use the Day, Month and Year functions to extract the
> elements of the current date:

>   x = Day(Date)
>   y = Month(Date)
>   z = Year(Date)

> When I run these calls in the debug window, they return the right
> answer. When I put them into my code, I get to these lines and it says
> Compiler Error: Expected Array. Can anyone help me? I'm about to throw
> VB5 in the garbage. But I'll save my ranting for another post.



Tue, 21 Sep 1999 03:00:00 GMT  
 Functions don't work in VB5?

I don't own VB5 (yet), so I am only guessing.

An alternative syntax for 'Date' is 'Date()', which VB3 always changes to
'Date'. Has this default behaviour changed in VB5?

GSK

: >
: > Hi all,
: >
: > I am trying to use the Day, Month and Year functions to extract the
: > elements of the current date:
: >
: >   x = Day(Date)
: >   y = Month(Date)
: >   z = Year(Date)
: >



Wed, 22 Sep 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. String extract functions, left,right.mid don't work

2. Date, Trim, STR Functions Don't Work

3. Function keys don't work until I display help

4. BUG: VB4(16 bit) - Int and Fix functions don't work correctly

5. Kill/Name function don't work after shell commands

6. Auto Indent don't work, VB5 prof

7. Set Printer=Printers(n) don't work in VB5

8. MovePrevious don't work but the MoveNext work's fine

9. Script works, script don't work

10. some time's it works, some time it don't

11. I've programmed a game that don't work Help

12. API/function doesn't stop and I don't understand it :o)

 

 
Powered by phpBB® Forum Software