Converting Decimal Number To Binary Form
How do I convert let's say decimal number 134 to binary form 10000110? And then how I manipulate the "bits" because after that converting the number is in second complement form and if it starts with "1" it's a negative number? So basically how do I make the converting from decimal to binary? Thanks!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Converting A Decimal Number To Binary
In my code I have convert numbers from Decimal to Binary and vice versa.
I have done the Binary to Decimal conversion but I am having trouble doing it the other way.
There is a HEX and an OCT function but no Binary function.
I'm sure there is something simple I am missing, can anyone help.
Thanks for your time.
SB
Converting Binary To Decimal
I need to convert an string of 3 characters which contains a number in binary code to a double variable. The coded number (which I read form a .dbf file) has two decimals, so I suppose it is stored in floating point format. Is there any function to do this in VB?
Thanks.
Converting Binary To Decimal
Is there a function that converts a binary number into a decimal and the other way around?
eg: 10011101 should return 157
eg: 156 should return 10011100
regards
Tom Cannaerts
slisse@planetinternet.be
The best way to escape a problem, is to solve it.
Converting Hex To Decimal
I am trying to convert the hex value 'FF FF FF FF' to decimal value but in VB, I seem to always get a -1 result. If I drop my bytes to 3 instead of 4, I get the correct answer. I tried the Cdec,Cdbl, Clng commands.
The windows calculator tells me the correct result for ...
FF FF FF FF is 4294967295
I would like to achieve this in my app.
Any pointers?
Converting Hex To Decimal
Hello,
My program communicates with an external device which I need to know the position of at any one time. I am able to request the postion via the MScomm1_OnComm event without any problem, however the value the piece of kit returns to me is in hex form.
Is there a simple function in VB to convert this value to a decimal value or do I have to convert it manually?
Many thanks
Converting Hex To Decimal
In VB 6.0 there is function called: Hex, which provided with a Decimal number returns a string containing its Hexadecimal value.
What I need is the contrary, provided a number in Hexadecimal base, I want returned it's decimal value.
But searching through MSDN I only found the Hex and Oct functions that convert decimal numbers to these bases. Isn't there a function that does what I need? Or will I have to do it myself?
Not that it's a hard thing to do (in fact it's easy) but I would be easier and more efficient if it were already done.
Thanks in advance!
Converting To HEX Decimal
OK i have this wizard on my application to setup colors in a HTMl document. However it spits out the long code like for white it is 16777215 how do i convert it to HTML Hex Decimal like #000000 for white? I cant use the long code in HTML documents..
Converting RGB To Decimal
My math is bad. I can convert decimal to RGB
but my brain is not able to convert RGB to decimal. heh
if I have
r=155
g=155
b=155
how can I convert this to decimal (10197915)
here is the code dec -> rgb
b.Caption = Int(CVal / 65536)
g.Caption = Int((CVal - (65536 * b.Caption)) / 256)
r.Caption = CVal - (65536 * b.Caption + 256 * g.Caption)
Thanks
Conversion Binary To Binary And Conversion Of Hexadecimal To Decimal In Calculator
Hi Folks
i was develop one scientific calculator
1) binary to binary conversion= for example we can add one binary value (1110) + another binary value(0101) = i want this output(100 1 1)but it comes 1211 this is my question how can i rectify ?
2) convert from hexadecimal to decimal conversions (ex)in decimal 12 to hexa is c . it wirks good ,but my question is how to convert hexadecimal to deimal (12) ?
Tks in Advance
----------------------------------------------------------------------
HARD WORK NEVER END FAILS"
Converting IP Numbers To Decimal
Hi guys...
I'm looking for a way to do this....
192.168.0.0 = 3 232 235 520
W .X .Y.Z
BUT... i can't make this in vb... overflow... tried Cdec, Variant, Currency... nothing works... even a string dosen't work... here's the formula...
N = W*16 777 216 + X*65 536 + Y*256 + Z
THANKS!
Converting Hex Byte To Decimal...
Hello VB people,
I would like to simply enter a hex byte into a text box, and be able to show the byte in a nother text box as a decimal. This probably simple, I've been mesing with it for an hour now and getting nowhere. Can anyone help.
Thanks in advance,
Chris
Western Australia
Converting Hex To Decimal Format
Here is what I am trying to do. I have a card reader that reads in an 18 digit decimal number. I then have my program convert that number to hexidecimal format. I am now trying to take that database and re-convert the hexadecimal number into the original 18 digit decimal format. When trying to use the following code I keep getting an overflow error, however, it does work on smaller Hexadecimal numbers. Does anyone have any suggestions? I really need help fast, I am on a very short deadline! Thanks to all!!
Private Sub Command1_Click()
Dim sHex As String
sHex = 2EEC07E9A9
MsgBox Hex2Dec(sHex)
End Sub
Function Hex2Dec(sHex As String) As Long
Hex2Dec = Val("&h" & sHex)
End Function
Jason
Converting To Decimal String
I have values being inputted through the serial port (Com1). The number being inputted is in binary but I want to convert it into decimal.
Below is what I have, but I am not completely sure if it is right. I want to make it as simple as possible. Thanks...
' convert numValue character string into hex string
numAscii = ""
For i = 1 To Len(numValue)
numAscii = numAscii + CStr(Hex(Asc(Mid(numValue, i, 1))))
Next
'convert hexNum string into decimal string
hexNumstring = numAscii
numLong = CLng("&H" & hexNumstring)
txtNum.Text = numLong
Also, I will have three different binary numbers being inputted. They will be inputted as three separate binary numbers but once they are decimal I want them to be combined. How can that be done?
To simply: Through the serial port, 0001, 0001, and 0011 is inputted separately, but I want the final value to look like: 113.
I am using VB6. Thanks..
Decimal And Hex Rgb Color Converting Help ?_?
hi, im new to this forom and ive been learning visual basic for about 1 week. i ran into a problem though....what im making at the moment is a ssa color generator (RGB) in hex or decimal (in 2 options). with some help, i have managed to be able to switch between the two options and hex and dec will change. but ive just realized somehow it inverts the numbers so the hex is diffenent from before and when its inverted again it becomes the original value.
i want it to say the correct colour each time.
heres the code:
VB Code:
Private Sub Option1_Click()If (Option2.Value = False) ThenIf (Color = "Hex") ThenDim myvar As StringDim mylong As Longmyvar = Text1.Textmylong = RGB(Val("&H" & Mid(myvar, 1, 2)), Val("&H" & Mid(myvar, 3, 2)), Val("&H" & Mid(myvar, 5, 2)))Text1.Text = mylongEnd IfColor = "Dec"End IfEnd Sub Private Sub Option2_Click()If (Option1.Value = False) ThenIf (Color = "Dec") ThenText1.Text = Hex(Text1.Text)End IfColor = "Hex"End IfEnd Sub
could someone please help me out here
thanks alot
Converting Time To Decimal
Does anyone know how to convert the result of the Time() function into decimals?
Example: 11:30 AM
Decimal: 11.50
Thanks in advance!
Jeff
Converting Hexadecimal To Decimal
There is a function Hex() to convert decimal numbers to hexadecimal numbers, but there seems to be no function to convert hexadecimal into decimal. Does anyone know how to do this?
Help Converting Hexadecimal To Decimal
Hi guys!
Could anybody tell me how to convert an hexadecimal number to decimal.
I mean the opposite of HEX function.
Thanks in advance.
Best regards.
Atilio
Decimal To Binary
i am trying to find a way to convert decimal to binary in vb, i searched around and found:
VB Code:
Dim Number As IntegerDim Binary_String As String Number = Val(Text1.Text)Binary_String = ""While Number > 0 Binary_String = Str(Number Mod 2) & Binary_String Number = Number 2WendText2.Text = Binary_String
this works fine except for it leaves spaces in between each character when i run it, what is wrong with this code?
Decimal To Binary
i'm programming a subnet mask calculator and i need to change a decimal value entered by the user to binary value which will be displayed in a label...any ideas?
Disco Duck
Decimal To Binary
just ewondering if there is a simple way of converting a decimal number to its binary equivalent
Binary To Decimal
I need to change a string which is a 12 bit binary value into its decimal equivilant.
Any easy way?
Cheers in advance
Andy Dunn
Decimal To BInary
Help
I need to change a deciml number, say 28 into its equivialnt binary pattern 011100?
Any easy way?
Cheers in Advance
Andy
Binary To Decimal
I need to convert a binary number, read from a text file, to it's decimal equivalent. It's in two's complement format, i.e can be negative.
Does anybody have a suitable routine or can anyone point me in the right direction?
Many thanks
Binary To Decimal Help!
Right now I have a VB project I need to complete for school. And to be honest I need a little help.
The project is to create a program to convert an 8 digit binary number into a decimal number. Remember I'm a newbie so please don't post functions.
1. I probably won't be able to understand them, and 2. I need to submit the source code with the program.
I understand prefectly how decimal numbers are calculated from binary. And all I really need to find out is the code for analysing each individual digit so I can tell VB to than if the first place is 1 make a variable with the vale 2^0 and if the second place is 1 make another with the value 2^1 etc... That really is the key to my sucess at the moment.
HEEEEEEEEEEEELLLLLLLLLLLLLLPPPPPPPPPPPPPPPP!
Hex/decimal To Binary
hi
i need to know if there is any way to convert hex or decimal to its equicvalent binay format
i need only 4 bit binary....
thanx in advance
sars
And miles to go before i sleep..........
Converting Decimal Value To String Output
hey all,
I would like convert a decimal number of inches ( 66.5 )
to a text string like-- ( 5'-6 1/2" )
can someone help
maybe a link to a page
or something
thank you
Converting LARGE Hex Numbers Into Decimal
Does anyone know of any function to convert a large hex number (held in a string) into a decimal number (held in a string). The hex numbers I am wishing to convert may be from 10 - 20 digits, this will make a big decimal number that must be held in a string.
Converting A String To Ascii Or Decimal Or Hex
can anybody help me convert a string entered into a textbox into its binary/dec/hex/ascii value?
I want to then, after incrementing the value, place the new value into another textbox as a string that the numbers represent.
I've tried the chr command, but learned that it is ony for the first character in the string.
Please help me...
mMiniImManN
Binary/Hex/Decimal Arithmetic
I need to do the following:
Code:
82 80 00 3 hex values
10000010 10000000 00000000 binary form of each
0000010 0000000 0000000 drop bit 7
000001000000000000000 concatenate
0000|0000|1000|0000|0000|0000 create 4-bit groups starting from right
0 0 8 0 0 0 hex value of each group
32768 decimal value of above
Anything I have attempted so far does not produce the correct result.
I am having trouble with the convert to binary part.
Help would be appreciated.
Binary/Hex/Decimal Conversions
Is there a function, API call, or something that can convert a binary/hex/decimal to binary/hex/decimal? I know Hex() does hex, but is there a way to do binary decimal and so on? Thanks.
Binary To Decimal And The Reverse
I am lost as to why this program doesn't work... with number over 255 any ideas I can't find a problem with the logic at all! Thanks here is the coding and it is in the sip file as well:
Code:
Dim i, Power, Number, DecNum As Integer
Dim Digit As Single
Private Sub cmdB2D_Click()
txtDecimal.Text = ""
Power = Len(txtBinary.Text)
Number = Val(txtBinary.Text)
For i = 0 To Len(txtBinary.Text) - 1
DecNum = DecNum + Right(Number, 1) * 2 ^ i
Number = Left(Number, Len(Number) - 1)
Next i
txtDecimal.Text = DecNum
DecNum = 0
End Sub
Private Sub cmdD2B_Click()
Picture1.Cls
Number = Val(txtDecimal.Text)
Do While Number >= 2
Num = Num & Number Mod 2
Number = Int(Number / 2)
If Number = 1 Then
Num = Num & 1
ElseIf Number = 0 Then
Num = Num & 0
End If
Loop
For i = 0 To Len(Num) - 1
Binary = Right(Num, 1) & Binary
Num = Left(Num, Len(Num) - 1)
Next i
If Len(Binary) <= 8 Then
txtBinary.Text = Format(Binary, "00000000")
ElseIf Len(Binary) > 8 Then
txtBinary.Text = Format(Binary, "00000000 00000000")
End If
End Sub
Thanks!
Decimal To Binary Converter
My code works, but I cant display the number in a good format...:
Code:
Private Sub cmdD2B_Click()
Picture1.Cls
Number = Val(txtDecimal.Text)
Do While Number >= 2
Num = Number Mod 2
Number = Int(Number / 2)
Picture1.Print Num
Loop
If Number = 1 Then
Picture1.Print 1
ElseIf Number = 0 Then
Picture1.Print 0
End If
End Sub
I get a Picture box that displays the binary Number vertically...I want to print it horizontally...got any idea's. I would really like to print it in the text box but that is not necessary!
Thanks in advance!
|