There's one major gripe I have with the VB language.. the With/End With block. Although it shortens code lines when setting lots of properties I find it harder to read, error prone when moving code around, and very awkward to debug since you can't just select the property and add a watch.
I never use this syntax in my own code, always preferring to have everything in long form, it doesn't increase typing too much with intellisense and we all have fairly large displays these days so line length is less of an issue as well.
So when using code I find on the net or from colleagues the first thing I do is remove with blocks. Getting fed up with this time consuming but quite dumb task I've created a Visual Studio macro to do it.
As an example, code with a With statement like the following;
Public Sub AWithExample()
With Me
.Text = "Hello"
.Tag = "This"
MessageBox.Show(.Text, "Title " & .Text)
Dim x As String
x = .Text
End With
End Sub
Becomes;
Public Sub AWithExample()
Me.Text = "Hello"
Me.Tag = "This"
MessageBox.Show(Me.Text, "Title " & Me.Text)
Dim x As String
x = Me.Text
End Sub
The Macro's quite trivial, just create a new macro and add the following code; More...