Dim x, y as Date
What is the difference between these two code statements
Dim x as Date, y as Date
What is the pragmatic result of the difference and what other hidden declaration features am I missing?
Dim x, y as Date
is the equivalent of:
Dim x
Dim y as Date
and that is the equivalent of:
Dim x as Variant
Dim y as Date
When you omit the type for a variable, it assumes the Variant type
Edit, per your question:
Dim a! ' same as Dim a as Short
Dim b@ ' same as Dim b as Currency
Dim c# ' same as Dim c as Double
Dim d$ ' same as Dim d as String
Dim e% ' same as Dim e as Integer
Dim f& ' same as Dim f as Long
ref: http://bytes.com/topic/visual-basic/answers/643371-declaration-shortcuts
Dim x, y as Date
As <Type> is required for each variable, so in the example above only y is a Date; x is a Variant (The default when no type is specified)
Dim x as Date, y as Date
Both variables are Dates as each has an As.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With