English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How can I convert number to a certain number system like binary to hexa. Our prof told us not to use the simple bin2hex function in excel.. Any ideas guys? That worksheet serves as our final laboratory exam.. Pls help me guys!!

2007-10-09 21:48:44 · 4 answers · asked by asTroboy69 2 in Computers & Internet Programming & Design

4 answers

If you paste the following functions into a VBA module in Excel, they should work. Convertbase10 will convert a number from a given base into base 10. For example, convertbase10(1111, 2) converts "1111" from base 2 into base 10 where it equals 15. ConvertNumber converts a number out of base 10 into the given base. For example convertnumber(15,2) = "1111". You can use the functions together convertnumber(convertbase10( 1111, 2), 16) would convert 1111 from binary to hex.

Function convertBase10(inputstring As String, inputbase As Integer)
lengthstring = Len(inputstring)
For counter = 1 To lengthstring
convertBase10 = NumeralLetter(Mid(inputstring, counter, 1)) * (inputbase ^ (lengthstring - counter)) + convertBase10
Next


End Function

Function ConvertNumber(inputnum As Integer, base2 As Integer)

Dim place(30)
Dim endresult As Double
Dim var1 As Long
Dim var2 As Long
Dim textstarted As Boolean
textstarted = False

workingnum = inputnum
For placeholder = 1 To 30

place(placeholder) = workingnum Mod base2
workingnum = workingnum - place(placeholder)
workingnum = workingnum / base2

Next
For placeholder = 30 To 1 Step -1
If place(placeholder) > 0 Or textstarted = True Then
ConvertNumber = ConvertNumber & LetterNumeral(place(placeholder))
textstarted = True
End If

Next
End Function
Function NumeralLetter(inputstring)
Select Case inputstring
Case 0 To 9
NumeralLetter = inputstring
Case "A"
NumeralLetter = 10
Case "B"
NumeralLetter = 11
Case "C"
NumeralLetter = 12
Case "D"
NumeralLetter = 13
Case "E"
NumeralLetter = 14
Case "F"
NumeralLetter = 15
Case "G"
NumeralLetter = 16
Case "H"
NumeralLetter = 17
End Select
End Function

Function LetterNumeral(inputnumber)
Select Case inputnumber
Case 0 To 9
LetterNumeral = inputnumber
Case 10
LetterNumeral = "A"
Case 11
LetterNumeral = "B"
Case 12
LetterNumeral = "C"
Case 13
LetterNumeral = "D"
Case 14
LetterNumeral = "E"
Case 15
LetterNumeral = "F"
Case 16
LetterNumeral = "G"
End Select
End Function

2007-10-10 14:26:45 · answer #1 · answered by Jeffrey C 3 · 0 0

I have some conversion formulas. They don't do all the possible conversion combinations, but may at least give you some ideas to get you started.

They're too complex to try and list here, so if you'd like to e-mail me an address through my profile, I'd be happy to send them to you.

Cheers.
.

2007-10-10 01:56:38 · answer #2 · answered by aladou 5 · 0 0

If cellular A1 has 2.5, this might upload 2.5 months to at the instant's date. The decimal part of two.5 is in keeping with a 30 day month. =DATE(3 hundred and sixty 5 days(at the instant()), MONTH(at the instant())+INT(A1), DAY(at the instant())+MOD(A1,one million)*30)

2016-12-14 13:01:49 · answer #3 · answered by Anonymous · 0 0

So you have been told what function to use.
Did you think about looking at Excel help?

2007-10-09 22:48:52 · answer #4 · answered by AnalProgrammer 7 · 0 1

fedest.com, questions and answers