Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Convert Decimal # To Another Number System


Use this to convert from decimal to another number system!!

Function DecodeValue(Base As Integer, ByVal dblCount As Double)
Dim i As Integer
Dim s As String
Dim Digitarray() As Integer
Dim Dividend As Double
Dim Quotient As Double
Dim Remainder As Double
Dim Divisor As Double

'Debug.Assert dblCount <> 255

i = 0

Dividend = dblCount
Divisor = Base
Do

ReDim Preserve Digitarray(i)


Quotient = Int(Dividend / Divisor)

If Quotient = 0 Then
Remainder = Divisor - (Divisor - Dividend)
Else
Remainder = Dividend Mod Divisor
End If

Digitarray(i) = Remainder
i = i + 1

Dividend = Quotient

Loop While Dividend > 0

DecodeValue = Digitarray

End Function

'Use the following to convert from Decimal to binary
' s = DecodeValue(2, 63)
'
' For i = 0 To UBound(s)
' out = s(i) & out
' Next




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Is There Any Built In Method To Convert Decimal Number To Binary Number In V.b 6.0
Hi everybody!

can u say whether any built in method is available to convert a given decimal number to binary number?


i can develope a user defined method for this. but i think it takes some extra time to execute... since i have to call this method repetedly...

thank you,
Regards:
raghunadhs.v

How Can I Convert A Decimal Number To A Binary Number?
How can I convert a decimal number to a binary number? Do you know if there's the function I can find in VB?

Thank you for your help!

Best Regards,

Kevin Shen

How To Take H:M:S And Convert It Into A Decimal Number. ???
I had a post similar to this earlier. That I needed to take a decimal number and convert it to H:M:S. Got that working.

I need to know how to take the time that is entered into 3 text boxes ( one for hours, one for minutes, and one for seconds),,, and convert that time into a decimal number.


Also... i have a procedure that makes an answer in this format... H:M:S

Can you tell me how to seperate that up, and display it in the 2 text boxes?

Thanks alot, you guys are a great help.

Convert Huge Hex Number To Decimal
Dear guys
I am trying to convert huge hex number to dec in Vb6 but I couldn't manage .
I found one function which it could convert 23 hex number to dec but I want to convert more for example 300 or even more.
I would like to ask you guys if you have source code for that ,please post it here .
Thank you .

How Can I Convert A Hex Number To Decimal(base 10)
  Hullo there...
Is there anybody who can light me up by showing me the way of converting a hex number to decimal (base 10)
except " &H number " which is perfectly working but not at run time (it can't work with variable; only with pure hex..).
I am here and open to suggestions. Thanks in advance...

Convert A Number To A String With Decimal Places
Hey...

I want to convert a number to a string using 10 digits and 3 decimal places... Is there a way to specify both?

Thanks

How I Can Convert Decimal To Hexa Decimal??
Hi,
I want to convert a decimal to hexadecimal in VB.

the value is more than signed32 bit.

i got one code ConvertDecimalToHexadecimal(ByVal Value As Double) from internet which is also giving overflow error.

Can anyone take up this challenge to help me out.

the decimal number for which i need hex(the number is a random generated one) = 11783197335

I need a quick response.

Thank you in advance

Hex To Decimal Convert
Hi,

I'm receiving an hexadecimal data throught the serial port of a device, for example:

Buffer = Buffer + MSComm1.Input

and when you read that buffer it tells you the value: 0F56 for example.
Now my question is how can I convert that hex value into decimal value so that I can actually plot it on a graph.

Right now I'm using,

Vplot = Val("&H" & Mid&(Buffer, n+1, 4))

But unfortunatly I end up getting a Run-Time error "13", type mismatch error message and it won't let me continue. Does anyone have any ideas?

Thatk you for your help,

Dan

Convert Hex To Decimal
I'm trying to convert hex to decimal. This is what I have:


Code:
Dim HexStr As Variant
Dim T As Variant

HexStr = "C145F67H"
T = Left(HexStr, 2)

Text1.Text = Int(Left(T, 1)) * 16 + Int(Right(T, 1))
What it should be returning is number 193, but I keep getting the type mismatch error. Please help. Thanks.

Convert Hex To Decimal
I have an exported file that has a set of numbers in Hexadecimal format. I would like to convert this into straight decimal format. Anyone know how to do this?

Hex To Decimal Convert?
Our system (SAP) show this value '0000C4E0' like '50400'. How should I do to show the value '0000C4E0' like '50400' with VB?

Convert Hex Into Decimal
I have a string containing a hexadecimal value. How co I get a decimal value out of it's contents?

Convert Hex To Decimal
Can someone tell me how to convert an Hexidecimal number to a Decimal number please, as i want to convert a hexadecimal colour of say a form to that of a decimal one...any1 know how?

How Do I Convert Decimal
to fraction? for example .5 should be 1/2, 1.5 should be 1 1/2.

thanks in advance...

How To Convert Hexadecimal To Decimal
how to convert hexadecimal to decimal

Convert Decimal To Binary??
Dumb question... is there a built in function to convert decimal numbers to binary?

ie. convert 164 to 10100100

Or am I going to have to write a function to do this?

lol, something I never thought I'd need to do.

Convert String To Decimal
How do I convert a string to integer value?
suppose I have a string "7498". This string is in hex value. I need to convert it to decimal. How do I do that?
I cannot find a function which allows me to convert from a string to hex then to a decimal. Please help.

Convert Decimal To Binary
Hello all,

I have just written a function to convert a decimal number into binary. The function works fine with just one problem, I need the number in eight bit binary format.

For example my code will convert the number ten into 1010. I need it to convert it so it reads 00001010. This is my current code;


Code:
Public Function inttobin(ByVal decnum As Long) As String
Dim binstring As Integer
Do While decnum <> 0
binstring = decnum Mod 2
inttobin = binstring & inttobin
decnum = Int(decnum / 2)
Loop
End Function
The only way I could think of achieving this was like this;


Code:
Public Function inttobin(ByVal decnum As Long) As String
Dim binstring As Integer

Do While decnum <> 0
binstring = decnum Mod 2
inttobin = binstring & inttobin
decnum = Int(decnum / 2)
Loop

Do While Len(inttobin) <> 8
inttobin = "0" & inttobin
Loop

End Function
but this seems a like a bad way to do it. Is there anyway I can make sure that the inttobin string is always 8 bits with any additional buffered bits being 0?

Convert A Decimal Into Its Digits?
Using VB6...

Is it possible (and can anyone give me help / code for) to isolate the individual values of a decimal? It certainly has me puzzled...

For example:
Say I had the value "18.20" in one text box, and I wanted to pass each value as a parameter to a different routine, which would display the number on a virtual LCD display. The values would have to be variables, obviously, and the Loop would have to work backwards from the 0, as there are always 2 decimal places.

I have already written the subs involved in the converting, I just need to pass the values to them... from a text box value in the format "00.00".



Said variables would then be passed to the subroutines via something along the lines of:


Code:
Call Sub1(Var1)
Call Sub2(Var2)
Call Sub3(Var3)
Call Sub4(Var4)


Yes, I know it's confusing. I'm confused. I've been programming for about 6 months. But help would be greatly appreciated. Thanks in advance.

Convert Binary To Decimal In VB
I've been looking for a way to do this for about two weeks now. Searching Google, Yahoo and even these forums. My question is. How can you convert Binary to Decimal? The app I am writing needs to take a binary number that someone enters into a text box, convert it to decimal and output that to another text box. This would be done with a button click event of course. I've got everything together except that part. I'm using Visual Studio 2005. Any help would be appreciated.

Convert Hex? Decimal? Ascii??
**



Edited by - Marce22 on 6/1/2005 11:23:36 AM

How To Convert Decimal # To Time?
hi,

let say, the user typed a number in the textbox "1.5". how can i convert it to 1 hr. and 50 sec. "1:50" because in normal "1.5" the same as "1:30".

thanks

sibasib



Edited by - sibasib on 10/21/2004 7:33:20 PM

Convert Seconds (with Decimal) To Hh:mm:ss?
Dear VBCity Friends,

Good Day! Currently, i am using a function to convert seconds (without decimal, 126815 Seconds) to hh:mm:ss!

But, when i try to use my functions to convert (with decimal, 1365489.322158) to hh:mm:ss, how come the time is different!

Please help & many thanks!

Code:Call formatTimeLength(time_elapsed)

Code:Private Function formatTimeLength(convertRT As String) As String
Dim X As String, ss As String, hh As String, mm As String

ss = convertRT 'convertRT=58677.3606033325 seconds
If ss >= 3600 Then
    hh = ss / 3600
    ss = ss Mod 3600
Else
    hh = 0
End If
If ss >= 60 Then
    mm = ss 60
    ss = ss Mod 60
Else
    mm = 0
End If

X = Format$(hh, "00:") & Format$(mm, "00:") & Format$(ss, "00")
End Function

How To Convert Decimal To Binary
I want to convert decimal to binary Help me please

How Do I Convert Binary To Decimal ?
I want to convert Binary to decimal with VB , can soemone pleasssssssssse help me , thanx a lot !

Convert String To Decimal
Hi folks

How to convert string to decimal in vb program
is there any API function is avalible
please give some sample coding for me.
-------------------------------------------------------------------
"HARD WORK NEVER END FAILS"

Decimal Number Become Fraction Number
Could you help me this problem:
How can I change a decimal number to fraction number?
For example:
0,3333 become 1/3
thank you!

Convert Long Format [1/2] To Decimal
How do I convert a double number, say 1.25 to a long format number, say 1 [1/4], and vise versa? Is there a function in vb 6 that will do it for me or do I need to write code (and what code would I write)?
Thanks!

Convert MSCOMM Data To Decimal
How van convert MSCOMM.input data to a decimal value which can be used to show into a chart.

Convert Positive Decimal Into Negative
Hi All,

I am doing an Access 2000 using VBA. I encounterd problem
converting positive digit into negative one and vice versa.

The case is like this, I had a list box when the user chose
"withdrawal", the amount(in a textbox) will be a negative value. On the contrary, if user chose deposit, the value will remain "positive". Can someone help me with the code and or the function.

Thanks alot.
Markus

Convert Decimal To Fractional Inches - Help
I found this code on the web and it works fine. It just doesn't convert the decimal to fractional inches. Any ideas?

It takes input in the format:

5' 8 3/4"

and outputs:

68.75

I need the .75 to be represented in inches.

Code:Function TotalInches(NewValue) As Single
    Dim Tmp&, Total As Single
    Dim Pos&, Measured$
    Measured = Trim$(CStr(NewValue))
    Pos = InStr(Measured, "'")
    If Pos Then
        Tmp = Val(Measured)
        Total = Tmp * 12
        Measured = Trim(Mid$(Measured, Pos + 2))
    End If
    Pos = InStr(Measured, " ")
    If Pos Then
        Tmp = Val(Left$(Measured, Pos))
        Total = Total + Tmp
        Measured = Mid$(Measured, Pos + 1)
    End If
    Tmp = Val(Measured)
    Pos = InStr(Measured, "/")
    If Pos Then
        Total = Total + CSng(Tmp / Val(Mid$(Measured, Pos + 1)))
    Else
        Total = Total + Tmp
    End If
    TotalInches = Total
End Function

SORRY - The above is now the correct function. :-)

Thanks,
Dave



Edited by - dcb007 on 3/23/2004 6:36:09 AM

How To Convert IP Address Binary To Decimal...
Hi everyone...

I wrote an IP address converter program a while back, and I was able to write the math to convert from decimal to binary, but not the reverse. So I ended up using a database for the reverse conversion. Does any math guru know the math to convert the IP address binary to decimal?

e.g. 01111111.00000000.00000000.00000001 to 127.0.0.1

Thanks in advance...

D-Race



Edited by - D-Race on 5/5/2005 3:56:43 AM

Suggest How To Convert Decimal To Binary
Please suggest me how to convert decimals to binary in VB.


Thanks

Haris

_____________________________________________________________________

How To Convert Hexidecimal To Decimal Or Binary
ive have been working with stirngs i use as hexidecimal values, i need to convert these strings to their deciaml values to send down a serial line as binary

can anyone show me how to convert hex to dec?
do i need to make the string into hex first or can i use them as hex already?

even better would be to convert these hex values straight to binary, any ideas?

Signature -----------------------------------------------------------------------------------------------------Code:Private Sub Form_Load() 'Print to from, code my problems!
     Form1.Print "CanT SleeP!..... MusT PrograM!!!" & vbCrLf & "I need coffee, WhErE iS mY CoFfEe?!"
End Sub 'All things come to and end
------------------------------------------------------------------------------------------------------------------

Edited by - coma on 11/24/2003 5:18:45 PM

Convert Column To String From Decimal
Hi,
I have a DataSet which I want to display in a Grid. The DataSet is retrieved from an Access table which has decimal numbers. Until here everything is straight forward. Now comes the question...

I need to customize the first row of my Grid to hold string values. I can insert a dummy row but I cannot enter string values in the cells. How do I convert a column of either the DataSet or the Grid to accept string values.

I could not use the following command
Code:mdleDataAccess.masterDataset.Tables(0).Columns(1).DataType = System.Type.GetType("System.String")

It throws up an error saying I cannot format the DataType after the DataSet has been filled. I tried adding columns to the DataSet before calling the "Fill" method, however that just adds additional columns to my DataSet.

This is the code I am using to connect to the database and retrieve data.

Code:
        myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dbLocation & ";"
        myConnection.Open()
        myCommand.Connection = myConnection
        myCommand.CommandText = "SELECT * FROM " & tableName
        myCommand.CommandType = CommandType.Text
        myDataAdapter.SelectCommand = myCommand
        masterDataset.Tables.Add(tableName)
        myDataAdapter.Fill(masterDataset, tableName)
        myConnection.Close()

Convert A Number Strored As Text To A Number Automatically!
Hi!

it´s possible convert a number strored as text to a number automatically,without lossing the non decimal number!!!?

thanks

Convert To Number The Number Stored As Text In Excel
can anyone help me on how to convert the number stored as text in excel when i exported my recordset in excel

this is how i exported my recordset
objExcel.Cells(2, 1).CopyFromRecordset ADODBRecordset

Help Me {convert Roman Numerals To Arabic Decimal}
how do i write a conversion function for a roman numerals to arabic decimal?

if possible please use basic commands and the like so that i can try an understand it.

thanks in advance

Convert Hours Mintues And Seconds Into Decimal
If I have 5:32:43 (5 hours 32 Minutes and 43 Seconds) is there a function to turn this into decimal (5.5453)

Thanks

[URGENT]from Double Convert To Percent Then To Decimal??
from double convert to percent then to decimal?? anybody can help me here!!!!!!!!!!!!!!!!!! tnx in advance...

Convert A String With A Decimal Point To A Value *RESOLVED*
I've done the usual search, but just can't seem to find an answer for this.

I've just read in a string, lets say PI -> "3.14159" and now I want to convert this to a value to use in calculating something in the program.

Interval = Val("3.14159") just returns the rounded integer portion of the number. How do I get the whole value including the numbers after the decimal point?


Edit: It helps to declare Interval as Double rather than Long !

How Do I Convert Hexadecimal To Decimal With Double Precision (64 Bit)
I want to convert a hex value to a decimal value with double precision. For example: 3FF0000000000000 would convert to: 99.000000000000000

I found this webpage that does the conversion. http://babbage.cs.qc.edu/courses/cs3...-754hex64.html

How would I code a function to do this in VB6?

Thanks.

**Resolved**- Round And Convert Into Decimal The Same Txtbox
I am a newbie looking for some expertise - I want to round the text box to two decimal places and convert into decimal the same text box - How can this be accomplished..

my code so far is as follows:

VB Code:
Private Sub Form_Load()Call openconnection Set RsRec = New adodb.Recordset     strsql = " select * from packing_specification" With RsRec    .CursorLocation = adUseClient    .Open strsql, objoCn, adOpenKeyset, adLockOptimistic                txtPACKINGSPEC = RsRec!packingspec        txtTARE = RsRec!tare        txtHEIGHT = RsRec!Height        txtLENGTH = RsRec!length        txtVOLUME = Round(RsRec!volume, 2)        txtWIDTH = RsRec!Width End With     If RsRec.EOF = True ThenMsgBox "No Packing Specs have been entered", , "Packing Specification"        End If Exit Sub On Error GoTo conerror: conerror:    MsgBox err.Description, vbCriticalEnd Sub


Thanks
holly

Decimal/binary Convert - Repetition Functions
im trying to make a binary/decimal convertor using repetition functions and no built in function. im having problems declaring the variables and using them in my algorithms. please help!!
--dec to bin--
set the bitstring to nothing
for each bit required in the bitstring
Calculate the remainder when the number is divided by 2
Number = Number 2 (integer division)
Bitstring = Remainder concatenated with the Bitstring
next bit
output the bitstring
--dec to bin--
set the bitstring to nothing
Do
Calculate the remainder when the number is divided by 2
Number = Number 2 (integer division)
Bitstring = Remainder concatenated with the Bitstring
loop until Number is zero
output the bitstring
--bin to dec--
Number = 0
for each character in the bitstring
Determine the value of the bit
Number = Number * 2 + Value of the bit
next character (moving rightwards through the bitstring)
output the Number

Probably Dead Easy, Convert Date To Decimal
I am sure this is easy to do, but what's the easiest way to convert a date into it's decimal equivalent.

i.e. 6:45 = 6.75 etc....

I know I could just frig it using math formulas but is there a built in VB function as I can't seem to find one.

Thanks For any help
Steve

Convert Binary To Decimal Manually Not Using Function
Does anyone have code to convert a binary Integer to decimal Integer? I need code to look at so I can understand how it is done. I want to use a loop to step thru the length and somehow calculate the numbers. I am not good in algebra. Thanks in advance for any help.

Having Problem To Convert 16bit Decimal To Byte Array
Hi, i need to get the 16 bit decimal to be converted into hexadecimal and store it into an byte array i.e.Dim lValue1 As Long, lValue2 As Long
Dim bArray(1) As Byte()

lValue1=76
lValue2=231

'Something the convertions like this below
bArray(0)=GetBytes(lValue1) ' i need to get &H4C
bArray(1)=GetBytes(lValue2) ' i need to get &HE7

End

I dont know how to write the 'GetBytes()' function. Can anyone please help me? Thanks!

Comport Read Code(how I Wil Convert Ascii To Decimal)
Respected Sir

I am facing problem to read data from comport I have used MSCOMM but i am getting data in ASCII code But i want it in decimal format How i will get it ?

Your help (sample code) and guidance is greately appreciated!

Regards

Bama

Copyright © 2005-08 www.BigResource.com, All rights reserved