Monday, September 29, 2008

Single Line If ... Then Using Colon For Multiple Statements

This might be a very simple one...
Many of you might know this before...
But, i just learnt it as part of my VB 2008 reading...

Its the If ... Then statement.

WHAT WE ALL KNOW IS

If intNetSalary = 10 Then
intGrossSalary = intNetSalary + intTax
End If


It can also be written as in one line:

If intNetSalary = 10 Then intGrossSalary = intNetSalary + intTax

But, in case of multiple statements within a If conditions...

If intNetSalary = 10 Then
intSubTotalSalary = intNetSalary + intMedicalDeduction
intGrossSalary = intSubTotalSalary + intTax
End If


THE NEW THING I LEARNT IS...IT CAN BE WRITTEN IN ONE LINE... HOW?

If intNetSalary = 10 Then intSubTotalSalary = intNetSalary + intMedicalDeduction : intGrossSalary = intSubTotalSalary + intTax

Isn't that great? I just learnt it...may be most of us don't know about it :)

~ Ram ~

Friday, September 26, 2008

Pascal Vs Camel Casing

Best Programming Practice:

Pascal Casing:
Pascal Casing - Its good to follow pascal casing while naming a method / function / sub.
e.g.: CalculateGrossSalary [All First Letter Of The Word Are Capital]

Camel Casing:
Its good to follow camel casing while naming a parameter.
e.g.: mySalary [It's Same As Pascal Casing But You Don't Capitalize the very First Letter.]


~ Ram ~

Single-Double Precision Floating Numbers

Single / Double Precision Floating Numbers:
In some cases decimal fractional components of numbers can go up to infinity [e.g.: pi], but computer don’t have that much space to hold, there has to be some limit at which computer stops keeping track of the digits to the right of decimal point.

Single-Precision Floating-Point number can only hold between -3.4 * 10^38 and +3.4 * 10^38.
Double-Precision Floating-Point number can hold between -1.7 * 10^308 and +1.7 * 10^308.

*Avoid using double-precision numbers unless otherwise needed for more accurate results [e.g.: Scientific Calculations].

~ Ram ~

Visual Basic 2008

Guru's, I just started reading Visual Basic 2008 just to keep myself updated in the technical world. When i started reading it, i came across few interesting, un-heard, nitty bitty things about VB-2008. So I thought of blogging it for myself if not for others as a quick reference.

Will keep posting it as i come across things which are different and new [Per My Knowledge]

~Ram~