Is VB really case insensitive?

后端 未结 14 2092
名媛妹妹
名媛妹妹 2020-11-30 05:28

I\'m not trying to start an argument here, but for whatever reason, it\'s typically stated that Visual Basic is case insensitive and C languages aren\'t (and somehow that is

14条回答
  •  情书的邮戳
    2020-11-30 06:05

    VB.NET is case-INsensitive.

    Examples:

    1.

    Dim a As Integer
    Dim A as Integer
    

    2.

    Sub b()
        'Some statement(s) here
    End Sub
    Sub B()
        'Some statement(s) here
    End Sub
    

    3.

    Function c() As Integer
        'Some statement(s) here
    End Function
    Function C() As Integer
        'Some statement(s) here
    End Function
    

    These all code will throw a COMPILE-TIME ERROR.

    For the 1st example, error will be shown, saying "Local variable 'A' is already declared in the current block.".

    While for the 2nd and 3rd example, error will be shown saying "'Public Sub b()' has multiple definitions with identical signatures." and "'Public Function c() As Integer' has multiple definitions with identical signatures.", respectively.

    From these errors, note that the errors are thrown at different positions for variables and procedures/functions. For variables, error is thrown at 2nd declaration while for procedures/functions it is thrown at 1st declaration/definition of identical code.

    As said by a user in a comment somewhere above, the VB.NET code is continuously checked and/or corrected in background; you can see this error in "Error List" window in VS IDE. And as this is AN ERROR and NOT A WARNING, the code will not compile until error is resolved.

提交回复
热议问题