5 Replies - 2294 Views - Last Post: 08 January 2010 - 07:56 AM

#1 tel0r   User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 27
  • Joined: 22-February 05

Decimal to Binary

Posted 14 June 2005 - 02:18 PM

Description: c&p following code:Convert Number to Binary string
Private Sub Command1_Click()
MsgBox Dec2Bin(1024)
End Sub

Function Dec2Bin(ByVal n As Long) As String
Do Until n = 0
    If (n Mod 2) Then Dec2Bin = "1" & Dec2Bin Else Dec2Bin = "0" & Dec2Bin
    n = n  2
Loop
End Function

Is This A Good Question/Topic? 0
  • +

Replies To: Decimal to Binary

#2 ronzam2002   User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 12-June 08

Re: Decimal to Binary

Posted 05 September 2008 - 11:11 PM

What kind of tool did you use in this 'Function Dec2Bin(ByVal n As Long) As String'?? does the message box only diplay 1000000..
Was This Post Helpful? 0
  • +
  • -

#3 rdsrds2120   User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 393
  • Joined: 18-December 08

Re: Decimal to Binary

Posted 26 February 2009 - 08:54 AM

i also only get 1000000. fix your code their.
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6257
  • View blog
  • Posts: 24,025
  • Joined: 23-August 08

Re: Decimal to Binary

Posted 26 February 2009 - 10:11 AM

The actual snippet is the Dec2Bin function. The test example is calling it with 1024, hence the 10000000 answer.
Was This Post Helpful? 0
  • +
  • -

#5 jakerman999   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 07-August 08

Re: Decimal to Binary

Posted 07 September 2009 - 04:10 PM

is there a way to go from hex to bin, and vice versa?
Was This Post Helpful? 0
  • +
  • -

#6 boka3090   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 08-January 10

Re: Decimal to Binary

Posted 08 January 2010 - 07:56 AM

third class programmer , no class
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1