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

Declaration shortcuts

danp129
Expert 100+
P: 321
I've been doing this for a long time in vb6 but don't see other's using it much...

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
May 8 '07 #1
Share this Question
Share on Google+
4 Replies


vijaydiwakar
100+
P: 579
I've been doing this for a long time in vb6 but don't see other's using it much...

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
No dear
this is a hidden aspect so every body don't know it
but I'm using it always
May 8 '07 #2

Expert 5K+
P: 8,434
The type declaration characters are simply the old way of declaring data types. As far as I know, the only advantage of the newer way (As Long, etc) is that they are much more straightforward to read.

I used these type characters in various versions of Basic for many years, but I can't remember most of them now (thanks for the handy reference). But there's much less chance of forgetting what "As String" means. Plus, I think that some new types such as Object, Variant and perhaps others, do not have a type declaraction character. Not too surprising, since they're only supported for backward compatibility.

It's a personal choice how you prefer to code, of course, but I would recommend using the newer method, so that others can read your code.

Oh, and by the way, VB6 doesn't have a Short data type. That would be Single.
May 8 '07 #3

danp129
Expert 100+
P: 321
The type declaration characters are simply the old way of declaring data types. As far as I know, the only advantage of the newer way (As Long, etc) is that they are much more straightforward to read.

I used these type characters in various versions of Basic for many years, but I can't remember most of them now (thanks for the handy reference). But there's much less chance of forgetting what "As String" means. Plus, I think that some new types such as Object, Variant and perhaps others, do not have a type declaraction character. Not too surprising, since they're only supported for backward compatibility.

It's a personal choice how you prefer to code, of course, but I would recommend using the newer method, so that others can read your code.

Oh, and by the way, VB6 doesn't have a Short data type. That would be Single.
Oops dunno why I typed short :P
May 8 '07 #4

Expert 5K+
P: 8,434
Oops dunno why I typed short :P
Been dabbling in other languages, have we? Traitor... ;)
May 8 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.