Saturday, April 10, 2010

VB's Missing Functions: Binary

Visual Basic is a great language, but it is missing some valuable functions, one of which is a Binary (Bin()) function. Below is some code I wrote to address this issue (special thinks to Bytewzrd for the idea).

VB.NET Code:
Function Bin(ByVal Number As Long) As String
Dim binval As String = ""
Dim nbr As Long = Number
While nbr > 0
binval = (nbr And 1) & binval
binval >>= 2
End While
Return binval
End Function



No comments:

Post a Comment