Quote:
Originally Posted by yihaaa
Wieso sollte das totaler Schwachsinn sein? Hier ist der ganze Code.
Code:
Function Dec2Bin(dec As Integer) As String
Dim x As Integer
x = 0
If dec >= 2 ^ 32 Then
Call MsgBox("Zahl ist größer als 32 Bit")
Exit Function
End If
Do
If (dec And 2 ^ x) Then '!!!
Dec2Bin = "1" & Dec2Bin
'MsgBox Dec2Bin & "/" & dec & "/" & 2 ^ x
Else
Dec2Bin = "0" & Dec2Bin
'MsgBox Dec2Bin & "/" & dec & "/" & 2 ^ x
End If
x = x + 1
Loop Until 2 ^ x > dec 'True
End Function
|
Lies den ganzen Post.
Übrigens ist VBA kein .net.
Und von Basis 10 zu Basis 2 macht man ganz sicher nicht so.
Code:
return (zahl == 0)
? zahl
: (zahl % zielBasis) + startBasis*konvertiere(zahl / zielBasis,
startBasis, zielBasis);
Geht problemlos bis Basis 10 ;o