Difference between Dim and Private

Dim declares and allocates space for a variable. Private is used to specify an access level that means only the declaring class can see or use the declared member.

I believe your question comes from the fact that you sometimes see things like:

Class MyDemoClass
   Dim mVar1 As Integer
   Private mVar2 As Integer
End Class

In the above example mVar1 and mVar2 declarations are logically equivalent – they both boil down to Private Dim mVar as Integer.

MSDN explains this here:

The Dim keyword is optional and usually omitted if you specify any of the following modifiers: Public, Protected, Friend, Protected Friend, Private, Shared, Shadows, Static, ReadOnly, or WithEvents.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)