Thread: dec2bin
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default dec2bin


this should do..

Function DecToBin(ByVal Number As Long, _
Optional Places As Integer) As String
Dim l As Long, s As String

l = Number
Do
s = (l Mod 2) & s
l = l \ 2
Loop While l 0
If Places 0 And Places Len(s) Then
s = String$(Places - Len(s), "0") & s
End If

DecToBin = s

End Function





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Jo wrote :

Hi
Is there something analagous to dec2bin (worksheet) for
VBA?
I need to change a 5 digit decimal into a 16 character
binary expression.
Thanks
Jo