I defined an global enumerator TimeStamp with several elements. Then I have this method:
[code]Public Function GetTimeStamp (ParamArray pMode AS TimeStamp) as String
// Some stuff
DIM i AS INTEGER
FOR EACH i IN pMode
SELECT CASE INT32 (pMode(i) )
CASE INT32(TimeStamp.Short)
ThisFormat = TimeStamp.Short
CASE INT32(TimeStamp.Long)
ThisFormat = TimeStamp.Long
CASE INT32(TimeStamp.Numeric)
ThisFormat = TimeStamp.Numeric
CASE INT32(TimeStamp.American)
ThisFormat = TimeStamp.American
CASE INT32(TimeStamp.AMPM)
ThisMode = TimeStamp.AMPM
CASE INT32(TimeStamp.Hour24)
ThisMode = TimeStamp.Hour24
CASE INT32(TimeStamp.DateAndTime)
ThisScope = TimeStamp.DateAndTime
CASE INT32(TimeStamp.DateOnly)
ThisScope = TimeStamp.DateOnly
CASE INT32(TimeStamp.TimeOnly)
ThisScope = TimeStamp.TimeOnly
END SELECT
NEXT
// More Stuff
End Function[/code]
The Compiler produces an error on the NEXT statement:
[quote]Globals.GetTimeStamp, line 58
Type mismatch error. Expected Integer, but got enum Globals.TimeStamp
NEXT[/quote]
If I try NEXT i then I get the same error.
Why is the compiler thinking i is a Globals.TimeStamp when i is clearly an integer?
Public Function GetTimeStamp (ParamArray pMode AS TimeStamp) as String
pmode is an array of time stamps
i is an integer
each element in pmode() IS a timestamp
FOR EACH ts as Timestamp IN pMode
SELECT CASE INT32 (ts) )
CASE INT32(TimeStamp.Short)
ThisFormat = TimeStamp.Short
CASE INT32(TimeStamp.Long)
ThisFormat = TimeStamp.Long
CASE INT32(TimeStamp.Numeric)
ThisFormat = TimeStamp.Numeric
CASE INT32(TimeStamp.American)
ThisFormat = TimeStamp.American
CASE INT32(TimeStamp.AMPM)
ThisMode = TimeStamp.AMPM
CASE INT32(TimeStamp.Hour24)
ThisMode = TimeStamp.Hour24
CASE INT32(TimeStamp.DateAndTime)
ThisScope = TimeStamp.DateAndTime
CASE INT32(TimeStamp.DateOnly)
ThisScope = TimeStamp.DateOnly
CASE INT32(TimeStamp.TimeOnly)
ThisScope = TimeStamp.TimeOnly
END SELECT
NEXT
// More Stuff
End Function
[quote=444193:@Alex McPhail] FOR EACH i IN pMode
SELECT CASE INT32 (pMode(i) )[/quote]
I is the VALUE of pMode, not the INDEX. FOR EACH iterates over the array without you bothering about the specific index. It just gives you each value from the array, one by one, in no particular order.