Simple property formatting In a VB.Net class, I have an method that replaces all square brackets [] in certain properties by normal brackets ().

Edit:
The program allows users to write custom calculations, such as [3-(6-2)]. Being able to use two kinds of brackets makes things easier for them, but when processing the calculation, it's easier to have the same brackets everywhere.

The code is really redundant:

Public Sub removeBadBrackets()
    ValueCalc = Replace(Replace(ValueCalc, "[", "("), "]", ")")
    TargetCalc = Replace(Replace(TargetCalc, "[", "("), "]", ")")
    LLLCalc = Replace(Replace(LLLCalc, "[", "("), "]", ")")
    LLCalc = Replace(Replace(LLCalc, "[", "("), "]", ")")
    LCalc = Replace(Replace(LCalc, "[", "("), "]", ")")
    HCalc = Replace(Replace(HCalc, "[", "("), "]", ")")
    HHCalc = Replace(Replace(HHCalc, "[", "("), "]", ")")
    HHHCalc = Replace(Replace(HHHCalc, "[", "("), "]", ")")
End Sub 


I think this could be done in a more efficient way, and I'd like to learn how.

Side note:


Those properties are not the only one of the object.
They are in the same region (although I am not sure regions can be used for anything else than my own convenience).


Thank you for your help improving this.
My VB.NET is incredibly rusty but you should write a separate function:

Public Shared Sub ReplaceBracketsWithParentheses(ByRef text As String)
    text = Replace(Replace(text, "[", "("), "]", ")")
End Sub


Calling code will then simply be:

Public Sub removeBadBrackets()
    ReplaceBracketsWithParentheses(ValueCalc)
    ...
End Sub 


Note that if you have to replace more than few substrings then a fluid approach may be more readable:

Public Shared Sub ReplaceBracketsWithParentheses(ByRef text As String)
    text = text.Replace("[", "(") _
               .Replace("]", ")") _
               .Replace("{", "(") _
               .Replace("}", "]")
End Sub




If you're translating some sort of mathematical expressions (but not only!) you may also consider to use a Regex.

One word about naming: I don't know the domain you're using this code but to me LLLCalc, LLCalc and so on are not descriptive names (and, anyway, acronyms should be cased PascalCase like LllCalc, the same is true for removeBadBrackets()).