#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default dec2bin

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What 'value' is a Dec2Bin output? EvilTony Excel Discussion (Misc queries) 12 April 13th 09 01:59 PM
=Dec2bin can you increase the number bits please WAT Excel Discussion (Misc queries) 0 July 29th 06 01:20 AM
How to get leading zeros using DEC2BIN scallyte Excel Worksheet Functions 2 December 8th 05 11:52 PM
Base number functions, example DEC2BIN Wayne Boswell via OfficeKB.com Setting up and Configuration of Excel 0 February 24th 05 04:18 AM
Dec2Bin Function Max length of 16 bits Rich[_15_] Excel Programming 1 September 22nd 03 06:13 PM


All times are GMT +1. The time now is 03:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"