3

In Visual basic 6, i declare a sub like this:

Private Sub test1(ByRef XmlFooOutput As String)
  ...
End Sub

Aafter that, I declare another sub like the following one:

Private Sub test2(ByRef xmlFooOutput As String)
  ...
End Sub

Automagically, the first method is transformed in:

Private Sub test1(ByVal xmlFooOutput As String)
   ...
End Sub

So the XmlFooOutput parameter is transformed in xmlFooOutput.

This is a pretty dangerous feature because methods like those could be mapped to different XSL presentation files that read XML values through Xpath. So when test1 parameter is renamed, XSL bound to test1 method goes broken because Xpath points to XmlFooOuput but the correct value is now in xmlFooOutput.

Is it possible to remove this weird feature? I'm using Microsoft Visual Basic 6.0 (SP6).

This question has some duplicates:

From what I see, there's no practical solution to disable this Intellisense evil feature.

Community
  • 1
  • 1
systempuntoout
  • 71,966
  • 47
  • 171
  • 241
  • I'm not able to replicate this behavior in VB6 SP5. Is this code in a form, module or class? –  Mar 15 '10 at 16:24
  • 3
    I'm a bit confused. VB6 is not case sensitive, so XmlFooOuput is the same as xmlFooOuput. If you want to ensure variables have different names in VB6, I believe you actually have to have differences other than the character case. – Seth Moore Mar 15 '10 at 16:25
  • @Heather This behaviour is in both form and module.Have not tried in class. @Smoore Confused for what?Do you think it is not weird? – systempuntoout Mar 15 '10 at 17:37
  • @systempuntoout That is very weird. Does it still do the same thing if you take care to type the second instance of `XmlFooOutput` in the exact same case as the first? –  Mar 15 '10 at 18:15
  • No, it does not.They stay equal with first letter upper case. – systempuntoout Mar 15 '10 at 19:07
  • Duplicate of this question http://stackoverflow.com/questions/248760/vb6-editor-changing-case-of-variable-names – MarkJ Mar 15 '10 at 21:44

2 Answers2

3

The case of variable names and other identifiers makes absolutely no difference to the language - VB6 is case-insensitive.

I agree it can be annoying when the IDE changes the case of identifiers automatically. There is already a detailed discussion of possible workarounds in this question.

Community
  • 1
  • 1
MarkJ
  • 30,070
  • 5
  • 68
  • 111
0

This is a feature of Visual Basic that probably originates back in QuickBasic, as has been pointed out stems from case insensitivity in names.

I tried the example of the OP and VB6 changes the declaration of test1() as described.

Its not possible to remove this feature - you will have to find another way round this.

quamrana
  • 37,849
  • 12
  • 53
  • 71
  • Actually we are living with this problem since 2005. Sometimes it happens that somebody in our team checkout some module, modify it adding another sub with different case, messing the other subs of the module. This is a subtle and awful bug that can be a pita to discover when you are developing because the renaming is done silently without warning. – systempuntoout Mar 15 '10 at 20:25
  • You need to find a way round this: Check your version control commits. Run your tests before committing. Best of all find a way of removing this requirement from your code. – quamrana Mar 15 '10 at 20:33