Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Contact info
Forum
 
Other projects
   Altirra

Search

Archives

01 Dec - 31 Dec 2013
01 Oct - 31 Oct 2013
01 Aug - 31 Aug 2013
01 May - 31 May 2013
01 Mar - 31 Mar 2013
01 Feb - 29 Feb 2013
01 Dec - 31 Dec 2012
01 Nov - 30 Nov 2012
01 Oct - 31 Oct 2012
01 Sep - 30 Sep 2012
01 Aug - 31 Aug 2012
01 June - 30 June 2012
01 May - 31 May 2012
01 Apr - 30 Apr 2012
01 Dec - 31 Dec 2011
01 Nov - 30 Nov 2011
01 Oct - 31 Oct 2011
01 Sep - 30 Sep 2011
01 Aug - 31 Aug 2011
01 Jul - 31 Jul 2011
01 June - 30 June 2011
01 May - 31 May 2011
01 Apr - 30 Apr 2011
01 Mar - 31 Mar 2011
01 Feb - 29 Feb 2011
01 Jan - 31 Jan 2011
01 Dec - 31 Dec 2010
01 Nov - 30 Nov 2010
01 Oct - 31 Oct 2010
01 Sep - 30 Sep 2010
01 Aug - 31 Aug 2010
01 Jul - 31 Jul 2010
01 June - 30 June 2010
01 May - 31 May 2010
01 Apr - 30 Apr 2010
01 Mar - 31 Mar 2010
01 Feb - 29 Feb 2010
01 Jan - 31 Jan 2010
01 Dec - 31 Dec 2009
01 Nov - 30 Nov 2009
01 Oct - 31 Oct 2009
01 Sep - 30 Sep 2009
01 Aug - 31 Aug 2009
01 Jul - 31 Jul 2009
01 June - 30 June 2009
01 May - 31 May 2009
01 Apr - 30 Apr 2009
01 Mar - 31 Mar 2009
01 Feb - 29 Feb 2009
01 Jan - 31 Jan 2009
01 Dec - 31 Dec 2008
01 Nov - 30 Nov 2008
01 Oct - 31 Oct 2008
01 Sep - 30 Sep 2008
01 Aug - 31 Aug 2008
01 Jul - 31 Jul 2008
01 June - 30 June 2008
01 May - 31 May 2008
01 Apr - 30 Apr 2008
01 Mar - 31 Mar 2008
01 Feb - 29 Feb 2008
01 Jan - 31 Jan 2008
01 Dec - 31 Dec 2007
01 Nov - 30 Nov 2007
01 Oct - 31 Oct 2007
01 Sep - 30 Sep 2007
01 Aug - 31 Aug 2007
01 Jul - 31 Jul 2007
01 June - 30 June 2007
01 May - 31 May 2007
01 Apr - 30 Apr 2007
01 Mar - 31 Mar 2007
01 Feb - 29 Feb 2007
01 Jan - 31 Jan 2007
01 Dec - 31 Dec 2006
01 Nov - 30 Nov 2006
01 Oct - 31 Oct 2006
01 Sep - 30 Sep 2006
01 Aug - 31 Aug 2006
01 Jul - 31 Jul 2006
01 June - 30 June 2006
01 May - 31 May 2006
01 Apr - 30 Apr 2006
01 Mar - 31 Mar 2006
01 Feb - 29 Feb 2006
01 Jan - 31 Jan 2006
01 Dec - 31 Dec 2005
01 Nov - 30 Nov 2005
01 Oct - 31 Oct 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 June - 30 June 2005
01 May - 31 May 2005
01 Apr - 30 Apr 2005
01 Mar - 31 Mar 2005
01 Feb - 29 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004

Stuff

Powered by Pivot  
XML: RSS feed 
XML: Atom feed 

§ Ugly variable definition syntax

In some programming languages, you must declare a variable by use, with a specific type:

ItemList count;

In other languages, you can declare a variable which can hold any type:

var item = document.getElementById('myForm');

In yet other languages, variables can be implicitly declared on use:

logOutput = DoCommand("somestring")

And then... there's Visual Basic.

Dim output As OutputWindow = env.GetOutputWindow()

Yuuuuuck! How do people stand this??

I don't ordinarily write Visual Basic code, but dug in a little bit in order to write a macro to provide the missing BuildStartupProject command that VS2005 still lacks. I'm not opposed to BASIC, but this has got to be the ugliest syntax hack ever, considering that DIM stands for "dimension" (it was originally used to declare sized arrays).

Comments

Comments posted:


My favourite are some graphics commands which were apparently inherited back from GW-BASIC-days to modern time VB. I googled this for drawing a line for instance: "picture.line (i+200,500)-(i+400,3000), vbBlue, BF". Oh yeah, that draws a box (BF parameter). Same thing with circles. When you're used to see obj.method(arg1, arg2, arg3) you suddenly get obj.method(arg1, arg2), arg3 !!

But maybe that's just me.

(sorry if double-post, but your preview seems to have forgotten to pass the data through :-p)

eloj - 12 06 06 - 10:02


Actually, this is configurable. You can set VB to define variables on initialisation. Check out:
http://msdn2.microsoft.com/en-us/library..).aspx

Steven - 12 06 06 - 10:43


VB's variable declaring is even uglier:
Dim a,b,c as Integer
What was declared here? (and if you answer 3 integers, the answer is wrong)

ender - 12 06 06 - 17:39


Yeah, that was the case up to VB6. However in VB.NET all of them will be Int32s.
But nevermind, there's plenty of reasons left why VB's still a pain in the ass.

Gregorius - 12 06 06 - 19:58


Itís just syntax; once you are used to it itís not that bad.

I especially like how you can do:
Dim fs As New System.CodeDom.CodeArgumentReferenceExpression()

instead of (C#):
System.CodeDom.CodeArgumentReferenceExpression fs = new System.CodeDom.CodeArgumentReferenceExpression();

Paul - 12 06 06 - 23:52


Yeah, I've definitely run into that problem a bunch of times -- it occurs in C++ too if you can't allocate on the stack. I believe that a solution is planned for both C++ and C# with type-inferred declarations, with "var fs" for C# 3.0 and "auto fs" for C++0x.

Phaeron - 12 06 06 - 23:59


On the other hand, the VB.net array syntax is just nasty...

How many elements does the following array have?
Dim a As Integer() = New Integer(500) {}
Answer: 501.

Oh well, at least they got rid of one-based arrays (thank god).

Paul - 13 06 06 - 00:21


instead of (C#):
System.CodeDom.CodeArgumentReferenceExpression fs = new System.CodeDom.CodeArgumentReferenceExpression();

That isn't that bad in Visual Studio. as soon as you hit the space after the 'w' in new, it will bring up IntelliSense and you just have to press '(' and everything in between it written for you.

What happens in:
Dim a,b,c as Integer
?

Bryan - 13 06 06 - 00:38


In "Dim a, b, c as Integer", "c" is an Integer and "a" and "b" are two Variants (variables which can hold any type). If you want declare 3 integers you must write "Dim a as Integer, b as Integer, c as Integer".

I use VB6 (not .NET) for 2/3 years and I don't think it's "ugly".
I've made many useful functionally programs without lots of problems.
I'm studying C/C++ in school and I understand that C is more "low level" than VB, but if you're developing a simple application which don't need low level istructions (obviously it can't be something like VirualDub) VB is perfect for it.

Sorry for my english, i'm italian.

LorenzoS - 13 06 06 - 05:03


When declaring variables in VB, you can save space (but increase hard-to-readability) by using the type character "%". The declaration would be:
Dim a%, b%, c%

Other type characters are & (Long), $ (String), # (Double), ! (Single) etc.

Johan - 13 06 06 - 05:50

Comment form


Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.
Name:  
Remember personal info?

Email (Optional):
Your email address is only revealed to the blog owner and is not shown to the public.
URL (Optional):
Comment: /

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.



Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.