A small function of VB6.0

Author:Anonymous    Updated:2008-2-25 18:40:33
Public Function DecToBin(DeciValue As Long, Optional NoOfBits As Integer = 8) _
As String
'********************************************************************************
'* Name : DecToBin
'* Date : 2003
'* Author : Alex Etchells
'*********************************************************************************
Dim i As Integer
'make sure there are enough bits to contain the number
Do While DeciValue > (2 ^ NoOfBits) - 1
NoOfBits = NoOfBits + 8
Loop
DecToBin = vbNullString
'build the string
For i = 0 To (NoOfBits - 1)
DecToBin = CStr((DeciValue And 2 ^ i) / 2 ^ i) & DecToBin
Next i
End Function
Previous:For VB loop in the structure and usage
Next:NO
User Reviews
Site Search
Related Articles
Recommended article
AD