C# guy driven crazy by what happens in VB when I press "ENTER"

Status
Not open for further replies.

David.Mater.Dei

New member
Joined
Apr 22, 2008
Messages
3
Programming Experience
1-3
In C#, I can start typing something, see the presumed word is correct (auto-complete a line), and hit ENTER, and keep typing on the same line. I don't have to press SPACEBAR or TAB. It's just something I like and am used to...

But I have to code some VB because of a grandfathered project and can't, for the life of me, stop hitting ENTER every bloody time I try to auto-complete a line, which drops me to a new line in VB, necessitating the BACKSPACE key, and including cursing as a side option.

I had my friend in stitches, as he commonly switches between VB and C#, and doesn't have a habit of pressing ENTER.

Anyway - if I can change the behavior of Visual Studio when coding in VB - that would be beautiful.
 
Another thing that C# lacks but VB offers is the 'With' statement.
With is ugly as sin, and because things can be "re-Withed" you end up with:

VB.NET:
With whatever
 .whatever
 With another
  .somethingElse
  With this
    With that
      .thing
    End With
 .thing4
 End With
 .some pages later
End With

Comes a point you havent got a CLUE what youre actually WITHing when you press ., without chasing up and down code, looking at indent levels.

This is what I'm getting at:
VB.NET:
            Dim sfd As New SaveFileDialog
            With sfd
                .Title = "Save xml file"
                .Filter = "XML|*.xml"
                .DefaultExt = "xml"
                .AddExtension = True
                .FileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & Path.DirectorySeparatorChar & "SomeFile.xml"
            End With
            If sfd.ShowDialog(Me) <> Windows.Forms.DialogResult.Cancel Then
            End If
 
Here are some bytecounts:

VB.NET:
[B]'334 bytes[/B]
Dim sfd As New SaveFileDialog
sfd.Title = "Save xml file"
sfd.Filter = "XML|*.xml"
sfd.DefaultExt = "xml"
sfd.AddExtension = True
sfd.FileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & Path.DirectorySeparatorChar & "SomeFile.xml"
If sfd.ShowDialog(Me) <> Windows.Forms.DialogResult.Cancel Then
End If

[B]'349 bytes[/B]
Dim sfd As New SaveFileDialog
With sfd
  .Title = "Save xml file"
  .Filter = "XML|*.xml"
  .DefaultExt = "xml"
  .AddExtension = True
  .FileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & Path.DirectorySeparatorChar & "SomeFile.xml"
End With
If sfd.ShowDialog(Me) <> Windows.Forms.DialogResult.Cancel Then
End If

[B]'352 bytes - let's use that With for all it's worth![/B]
Dim sfd As New SaveFileDialog
With sfd
  .Title = "Save xml file"
  .Filter = "XML|*.xml"
  .DefaultExt = "xml"
  .AddExtension = True
  .FileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & Path.DirectorySeparatorChar & "SomeFile.xml"

  If [COLOR="Red"].ShowDialog(Me)[/COLOR] <> Windows.Forms.DialogResult.Cancel Then
  End If
End With

Horses for courses, but I'll take the first form any day..
With = nasty ;)
 
"bytes"? The With statement is for saving keypresses, not bytes. And the blocking like other indentation makes for readability. About nesting it's a balance about keeping it simple and readable.
I avoid huge nests if possible
Ya too.
But they are perfectly happy to type End With, End For, End Function, End Try, End... Yada! How many cahracters did you have to type with all those End XXX when in C# we just type }
Lame statement. None, they are not typed, the IDE generates them.
appreciate that C# is a case sensitive language
That is not appreciated, it should be depreciated.
 
"bytes"? The With statement is for saving keypresses, not bytes.
And how many more times is code read than written? With is too easy to abuse and can generate really ugly code. Intellisense preselects the most recently used member (in C# anyway) so pressing "s" will preselect "sfd" in JB's example, and I reckon it'll take fewer keypresses to type that lot than using With.. I do agree that With saves keypresses, but I think it's a bridge too far

End of the day, were debating opinion here, and my opinion is that With realises code that is ugly as sin and is a construct for lazy people

None, they are not typed, the IDE generates them.
You assert that you have never typed the words necessary to end a block of code in VB? Cmon..

..And at precisely what point did I start advocating that C# is all about typing fewer characters anyway? My only contribution on the topic has been in response to VB guys asserting that
a) that's what C# is about (and I inferred it's not what i'm about) or
b) construct X means less typing in VB (and therefore VB must be better than C# for reason Y)

I'll state again, that code is read more than written. VB is more wordy than C#. I find C# much cleaner and easier to read. Oddly enough I have had non-english natives note to me that they prefer to read VB because it is more like english. It's worth noting that all of these people grew up and became familiar with a non-C style language first, and ported to C later.

I will always find english easier than spanish or french, I will always perfer lowercase to uppercase (most societies teach children lowercase letters first; the brain is much slower at reading uppercase than lowercase)
I guess really what we are talking about here is what youre most natively comfortable with..

..which is straying a little from the argument that the VB IDE is more retarded than the C# one (in 2005). Sorry, but it is. You have fewer options, less control, and not as much effort has gone into things like refactoring; that time was put into efforts like background compilation that help negate the inherent problems of allowing lax programming practices (Option Strict/Explicit)

That is not appreciated, it should be depreciated.
It ought be noted that depreciation is not the opposite of appreciation ;)
 
Last edited:
Response to C# guy

Hi im quite new at Vb.net, started it at the beginning of this year, but I just have a question for some of you,
I thought forums were about getting help from people in the know about things, not to be criticised about the kind of questions you ask.
How do you expect people like me to ask q's if you gonna shoot them down.
Now to the C# guy i don't know if this is what you're looking for, but I press "Control" and Enter at the same time.
 
criticised about the kind of questions you ask.
I'm lost. I've re-read the thread but I cant quite see what point this relates to, in any post. Perhaps you'd like to outline what you think is a criticism so we can be more sensitive to your needs?

How do you expect people like me to ask q's
I usually find that setting out a list of facts of where I am, making a statement about the goal I'm trying to reach, and perhaps a few words on what I've already tried or solutions I have envisaged, best empowers respondents to assess:
Whether I have formed a workable solution
The problem with my solution
A better solution

Given that I'm asking other programmers about a programming problem, I find that a woolly, over-wordy, indirect or confused statement doesnt work well. Short sentences with one purpose, just like the programs we create, work best

I also ensure that I include at least one sentence that terminates with a question mark; you'd be amazed how many posts I see where the OP just talks about the stage they are at leaving us non the wiser as to whether they actually have a question. End of the day, the advice you get here is free, so it's good etiquette to provide as much supporting information as you would like to receive in a solution. If you want a wone word answer, write a one line question. If you want a fully guided list of points including cocde samples, provide a similar effort when asking your question. Writing "My program's crashing; what's wrong?" wont elicit a very helpful repsonse.

(I write this as a genuine and sincere response to your post, because you state "I have a question" but your post *doesnt* actually contain a question mark! ;) )


if you gonna shoot them down.
End of the day, I personally dont find anything outlandish about this particular debate - and that's precisely what forums are for; Discussion. Everyone here in this thread who isnt running around saying "oh, i'm so hurt by the nasty way the internet is" has potentially learned something - e.g. nearly every time JohnH speaks, I learn something and I really value that his differing opinions are strong enough to stand up to mine, because there are times when I'm not asking him for information, but debating with him. (I know it seems like I single out John here, but genuinely, he stands out in my mind as most often the only person who answers the questions I ask)

If youre new to the internet, or maybe just social interaction with a wide variety of people that includes the cynical, sarcastic type who dont exist to bend over backwards to ensure that youre happy above answering your question, then I strongly suggest that you man up a little and accept this sort of thing for what it is; debate, discourse, conflicting opinions, call it argument if you want - the important thing is that people learn, and they go on with their day without sulking because someone in a different time zone expressed an contra-opinion in a way they didnt like


Now to the C# guy i don't know if this is what you're looking for, but I press "Control" and Enter at the same time.

See, you could have totally just made that point, without putting the previous 3 lines of complaining in there; such complaints tends to make long-time (read: cynical) internet users suspect that youre merely one of the original posters, re-registered under a new nick to "provide support" to "another" individual who feels hard done to. Thanks for the input, because it's something that puzzled me about VB intellisense for a long time :)
 
I find this thread very informative and (in my opinion) this thread has turned into a detailed discussion about the differences between C# and VB.Net.
 
Indeed, though we should perhaps make an effort to keep it on track of the differences between the C# IDE and the VB.NET IDE rather than the languages themselves.. Which I guess means no more discussing of with ;)

One thing I do like about the VB IDE is that it indents blocks immediately.. Sometimes the C# IDE needs a bit of coaxing to indent the blocks (I find myself deleting and re-typing the end }, or using "Format Selection") and syntax errors occasionally stop it from indenting (Which in turn can be a good indicator of a problem)
 
Heh, I love these religious wars on different languages.
My theory? It's 2008. Any language that forces you to write in a case sensitive manner is retarded.
 
Your theory makes about as much sense as proclaiming: "It's 2008. Any [computer programming environment] that forces you to write in English is retarded"
 
Heh, I love these religious wars on different languages.
This thread is not about religious language wars, it's about a particular behaviour of IDE code editor, that with some posts got slightly off topic to discuss other things IDE ++. I think the original request has been answered sufficiently and is closing the thread to avoid further diversions.

You all feel free to enter the Break Room whenever you feel like telling the world how retarding or not you think VB.Net is.
 
Status
Not open for further replies.
Back
Top