Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,572 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,925 people online right now. Registration is fast and FREE... Join Now!




Converting 12 digit numbers to binary

 
Reply to this topicStart new topic

Converting 12 digit numbers to binary, This works for numbers with 10 digits but not above. I have tried rede

conorshan
15 May, 2008 - 06:42 AM
Post #1

New D.I.C Head
*

Joined: 15 May, 2008
Posts: 1

CODE

Private Sub convertCmd_Click()
Dim binary As String
Dim n As Long
n = inTxt.Text


Do Until n = 0
    If (n Mod 2) Then binary = "1" & binary Else binary = "0" & binary
    n = n \ 2
Loop

outTxt.Text = binary

End Sub

User is offlineProfile CardPM
+Quote Post

jeronimo0d0a
RE: Converting 12 Digit Numbers To Binary
15 May, 2008 - 08:13 AM
Post #2

D.I.C Head
**

Joined: 3 Mar, 2008
Posts: 141


My Contributions
Your code ran just fine when I tried it. Eventually you will overflow a long, though. Are you using the 64bit long? 32 bits would overflow in a hurry. You could also use a long double, though that would lose precision. As a final option, you could do your own long division in the subroutine and process very large numbers.
User is offlineProfile CardPM
+Quote Post

sam_benne
RE: Converting 12 Digit Numbers To Binary
15 May, 2008 - 11:54 AM
Post #3

D.I.C Regular
Group Icon

Joined: 16 Jan, 2008
Posts: 298



Thanked: 1 times
Dream Kudos: 400
My Contributions
I have no idea what this is but looks interesting so time to google and get learning lol.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:58PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month