As I remember it the Private keyword (re variables) was introduced in vb2 or vb3 simply to complement the new Public keyword. The latter became preferred over the previous (and still existing) Global keyword.I don't think using Dim is different from using Private except that the latter makes your code more self documenting.
At module level there is no difference between Private and Dim.
"Private" seems better to use in order to keep a contrast against variables declared "Public", and may also help in understanding code easier, as HughLerwill mentions.
"Private" cannot be used to declare a variable in a proceedure, as strongm was showing.
Sorry, I meant "when dimensioning a variable at the top of the form" That is what I was questioning what was the difference if any. It works at the top of my forms just as it does in a module (but I agree not in a procedure).
So it is a historical thingy?
>It works at the top of my forms just as it does in a module
Both are modules: There are normal bas modules and there are class modules, which the latter is what you see in the form code window.
>So it is a historical thingy?
As far as I know, it was introduced for the reasons already mentioned by HughLerwill and myself.
Well Public, Private and Friend were really introduced when VB shifted to being based on COM and allowing us to write classes. The idea was that they were closer to what C++ used.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.