Is VB really case insensitive?

后端 未结 14 2006
名媛妹妹
名媛妹妹 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.

    0 讨论(0)
  • 2020-11-30 06:07

    I can only offer this, which as I recall from my programming text books back in the early 80s, is that case senstive languages were, (at that time) strictly intended to reduce compile time errors. That is to say, the "strictness" was intended to develop a coding discipline of greater accuracy. As it has turned out the addition of proper labeling of variables, classes, methods, functions, and whatever else you wish to throw in there, evolved as well.

    I recall almost all of those books included a recommended pattern for leading capitalization, lower case, etc. As we all know, much of that has been thrown out or should I say, ignored in practice, save for the high end production houses, and CASE solutions, or for those that have reached a higher skill level. I think everyone experiences this learning curve.

    Given the advancement of these langauges and IDE's, the better question becomes, which language improves my dev time? Of course if you are not familiar with each of the various langs, your options are limited.

    0 讨论(0)
提交回复
热议问题