Lee W, MVP
asked on
Object instead of Integer?
Can anyone think of a good reason to declare variables as objects instead of the appropriate variable type in VB6?
I'm experimenting with converting a VB6 app to .NET (2008 for now, then, if it works, 2017) and looking over the code, the original dev declared everything as objects. Dim intLoop1 As Object (why not integer?) Is there (could there be) a good reason for this or was he being lazy as my gut tells me?)
Thanks!
I'm experimenting with converting a VB6 app to .NET (2008 for now, then, if it works, 2017) and looking over the code, the original dev declared everything as objects. Dim intLoop1 As Object (why not integer?) Is there (could there be) a good reason for this or was he being lazy as my gut tells me?)
Thanks!
Objects are not the same as variables. Variables contain values whereas objects are, well, objects like Dictionaries or Collections.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I can see defining things as objects when you're not sure what kind of data they may contain... but then why name the variables after the type data you expect it to contain? Examples:
I would expect the variable names to reflect that they are objects:
At this point, the above question is rhetorical. I thank you all for your quick info and insight.
Dim intCounter As Object
Dim strSomeText As Object
intCounter = 1
strSomeText = "Fun to be lazy"
I would expect the variable names to reflect that they are objects:
Dim objCounter As Object
Dim objSomeText As Object
objCounter = 1
objStrSomeText = "Fun to be lazy"
At this point, the above question is rhetorical. I thank you all for your quick info and insight.
I agree to your POV. Being specific in the name and unspecific in the type just doesn't make sense.
You’re welcome and I’m glad I was able to help.
If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange MVE 2015
Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.
Marty - Microsoft MVP 2009 to 2017
Experts Exchange MVE 2015
Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
Did you used to be in sales Martin...?
;-)
;-)