What does DIM stand for in Visual Basic and BASIC?

后端 未结 10 2157
忘掉有多难
忘掉有多难 2020-11-30 20:39

What does DIM stand for in Visual Basic?

10条回答
  •  执念已碎
    2020-11-30 21:05

    The Dim keyword is optional, when we are using it with modifiers- Public, Protected, Friend, Protected Friend,Private,Shared,Shadows,Static,ReadOnly etc. e.g. - Static nTotal As Integer

    For reference type, we have to use new keyword to create the new instance of the class or structure. e.g. Dim lblTop As New System.Windows.Forms.Label.

    Dim statement can be used with out a datatype when you set Option Infer to On. In that case the compiler infers the data type of a variable from the type of its initialization expression. Example :

    Option Infer On
    
    Module SampleMod
    
    Sub Main()
    
     Dim nExpVar = 5
    

    The above statement is equivalent to- Dim nExpVar As Integer

提交回复
热议问题