Archive forSeptember, 2011

VB Quark #5: C is for Char

Can you pick the problem with this code ? :       Dim currentChar As Char       For i = 0 To largenumber          currentChar = getChar(i)          If currentChar = "a" Then             count += 1          End If       Next   The answer of course is the literal “a” is of type string, not of type Char. […]

Click here to read more »

VB Quark #4: type literals

Do you know why you can’t write this code in VB:    Dim x = 123456789.0123456789 Answer: The IDE won’t let you If you try to write that code the IDE will truncate the number, giving :    Dim x = 123456789.01234567 To include all the decimal places you need to be using the Decimal […]

Click here to read more »

VB Quark #3: operator differences in VB/C#

Can you spot the problem with this code:    <Extension()>    Public Function ToColor(argb As UInteger) As Color       Return Color.FromArgb( _                       CType((argb & &HFF000000) >> &H18, Byte), _                       CType((argb & &HFF0000) >> &H10, Byte), _                       CType((argb & &HFF00) >> 8, Byte), _                       CType(argb & &HFF, Byte))    End Function   If you said it should […]

Click here to read more »

VB Quark #2: compiler directives and constants

Building upon VB Quark #1 , did you know you can use compiler directives alongside expressions in constants ? #If CONFIG = "Debug" Then    Const path As String = "Z:\mydebug.sdf" #Else    Const path As String = "|DataDirectory|\Database1.sdf" #End If    Const connectionString = "Data Source=" & path The nice thing about this is as you change […]

Click here to read more »

VB Quark #1: constant expressions

This quark is more of a did ya know quark about constant expressions in VB. You probably know you can declare a constant expression such :    Const appName As String = "My Really Cool App" But did you know you can also do operations in constants ? Rather than calculate the area of a circle […]

Click here to read more »

VB Quark #0 : lambda expressions and statements

This VB Quark is the one that started the conversation some weeks back. It’s number 0, both because these days things are typically 0 based in .NET, and also you could say it is ground zero. It’s about a quirk quark to do with lambda functions versus lambda subs. Let’s say you have a Customer […]

Click here to read more »

VB Quarks …

A few weeks ago I was having a discussion about a particular language feature that was causing a couple of people to trip up in their code. From that discussion we identified some places where the VB compiler and IDE can possibly help in the future; but for today there are some language features that […]

Click here to read more »

Windows Phone Mango and multiple google calendars

With Windows Phone 7.5 (aka Mango) being released in the next couple of weeks, you may have to work around a google limitation to get multiple google calendars on your device. Both Windows Phone 7.5 and google calendar allow you to have multiple calendars on your phone, but for whatever reason Google doesn’t let you […]

Click here to read more »