| | |
decimal to binary
![]() |
•
•
Join Date: Mar 2009
Posts: 3
Reputation:
Solved Threads: 0
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim a As Integer, i As Integer, b(20) As Integer, c As Integer, d As Integer i = 0 a = TextBox1.Text While a > 1 b(i) = a Mod 2 a = a / 2 i = i + 1 End While b(i) = a While i >= 0 c = c & b(i) i = i - 1 End While Label5.Text = c Label5.Visible = True
hey guys i wrote the above prog to convert decimal to binary the result i get is wrong for the last digit..
eg when converting 100 i get 10100100 instead of 1100100
thanks in advance..
HI
Use \ operator instead of / operator, because / operator in vb gives floating result and \ operator gives integer result. so floating value will be rounded to integer.
For example
3 / 2 gives 1.5 and it will be converted to 2
Use \ operator instead of / operator, because / operator in vb gives floating result and \ operator gives integer result. so floating value will be rounded to integer.
For example
VB Syntax (Toggle Plain Text)
Dim a as Integer a = 3 / 2 MsgBox a ' Gives 2 a = 3 \ 2 MsgBox a ' Gives 1
Last edited by selvaganapathy; Jun 10th, 2009 at 2:00 pm.
KSG
![]() |
Similar Threads
- Help With Decimal to Binary conversion (IT Professionals' Lounge)
- Converting Decimal Value to Binary (MIPS) (Assembly)
- decimal to binary conversion (C++)
- Convert decimal to binary and with base the 8 (C)
- decimal to binary conversion (C++)
- decimal > binary > Oct > Hex (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Deleting Record from Listbox and Sorting a list box
- Next Thread: Listview issue
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





