dec2bin

  • Thread starter Thread starter Jo
  • Start date Start date
J

Jo

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
 
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 :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top