Как перевести число в двоичную систему ищесления.

Dim bin As String, dec As Long
dec = Val(Text1.Text)
Do While dec > 1
bin = Str$(dec Mod 2) & bin
dec = dec \ 2
Loop
bin = Str$(dec) & bin
Text2.Text = bin
function DesR(byval chislo as long,byval por as long)
Dim bin As String
if por <0 or por>16 then
msgbox "Неправельный порядок системы"
end
end if
prevod = array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F")
bin=""
Do While chislo >= por
bin = perevod(chislo Mod por) & bin
chislo = chislo \ por
Loop
DesR= Str$(chislo) & bin
end function
function RDes(byval chislo as string,byval por as long)
Dim mn as long, per as long,i as long, j as long
if por <0 or por>16 then
msgbox "Неправельный порядок системы"
end
end if
prevod = array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F")
mn = 1
per=0
for i=len(chislo) to 1 step -1
for j=0 to 15
if prevod(j) =mid(chislo,i,1) then
per =per+ j*mn
exit for
end if
next j
mn= mn* por
next i
RDes =per
end function
Сейчас этот форум просматривают: Google-бот и гости: 3