VB6 Editor changing case of variable names

前端 未结 10 971
迷失自我
迷失自我 2020-12-08 13:24

I\'m not much of a Visual Basic person, but I am tasked with maintaining an old VB6 app. Whenever I check out a file, the editor will replace a bunch of the uppercase varia

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 13:57

    I have had a similar enumeration problem where for no apparent reason UPPERCASE was changed to MixedCase.

    Enum eRowDepths
        BD = 1
        CF = 1
        Separator = 1
        Header = 3
        subTotal = 2
    End Enum
    

    When I changed to the following (tailing the last character of the non-conforming variables), I had no problem

    Enum eRowDepths
        BD = 1
        CF = 1
        SEPARATO = 1
        HEADE = 3
        SUBTOTA = 2
    End Enum
    

    It turns out that this is a case of the tail wagging the dog. I have the following code, not the most elegant I admit but working nonetheless (please excuse formatting issues):-

    'insert 3 rows
      iSubTotalPlaceHolder = i      
      rows(ActiveSheet.Range(rangeDMirrorSubTotals).Cells.Count +  _
                                                            Header _
                                                             & ":" _
          & ActiveSheet.Range(rangeDMirrorSubTotals).Cells.Count + _
                                                          Header + _
                                                        subTotal + _
                                               Separator).Insert
    

    So it seems that the compiler won't accept explicit UpperCase constants as part of this statement.

    This was acceptable

    Dim fred as Integer
    fred = SEPARATO + HEADE + SUBTOTA
    

    So my work-around is to use a variable instead of the constants as part of the complex insert statement if I want to stick to the rule of keeping enumerated constants uppercase.

    I hope this is of use

提交回复
热议问题