1樓:匿名使用者
private function dectopoint(value as long, flag as long) as string
dim c as long
dim r as long
c = value if flag = 16 then
dectopoint = hex(c)
exit function
end if
dim s as string
dor = c mod flag
c = int(c / flag)
s = s & cstr(r)
loop until c < flag
s = s & cstr(c)
dectopoint = strreverse(s)
end functionprivate sub form_load()
dim value as long
value = 123
msgbox "value的二進位制
: " & dectopoint(value, 2)
msgbox "value的八進位制: " & dectopoint(value, 8)
msgbox "value的十六進位制: " & dectopoint(value, 16)
end sub
編寫vb程式 編寫sub過程 把任意一個十進位制數n分別轉換成二進位制八進位制十六進位制表示的數
2樓:匿名使用者
設計介面
:**:
private sub command1_click()
dim integerpart as long, decimalpart as double
dim carry(), charactercode(15) as string
carry = array(2, 8, 16)
integerpart = int(val(text1.text))
decimalpart = val(text1.text) - int(val(text1.text))
for i = lbound(charactercode) to ubound(charactercode)
select case i
case 0 to 9
charactercode(i) = chr(48 + i)
case else
charactercode(i) = chr(55 + i)
end select
next i
for i = lbound(carry) to ubound(carry)
label2(i) = transformation(carry(i), charactercode, integerpart, decimalpart)
next i
end sub
private function transformation(byval carrysystem as integer, byref charactercode() as string, byval integerpart as long, byval decimalpart as double) as string
dim r as integer, strintegerpart as string, q as integer, strdecimalpart as string
dor = integerpart mod carrysystem
integerpart = integerpart \ carrysystem
strintegerpart = charactercode(r) + strintegerpart
loop until integerpart = 0
doq = int(decimalpart * carrysystem)
decimalpart = decimalpart * carrysystem - q
strdecimalpart = strdecimalpart + charactercode(q)
loop until decimalpart = 0
transformation = strintegerpart + "." + strdecimalpart
end function
執行介面:
將十進位制數902.348轉換為二進位制數、八進位制數和十六進位制數。
3樓:北京瑞星資訊科技股份****
902:
1110000110;
1606;386
348:
101011100;534;15c
902.348:
1110000110.010110010001011010000111001010110000001;
1606.2621320712601;
386.5916872b02。
4樓:匿名使用者
二進位制:1110000110.01011001000101101000011100101011
vb編寫程式,利用sub過程實現將任意一個十進位制數n分別轉換成2進位制、8進位制和16進位制數。 要求
5樓:聽不清啊
private sub command1_click()a = cint(text1.text)
s = ""
dec2n a, 2, s
print a; "=("; s; ")2"
dec2n a, 8, s
print a; "=("; s; ")8"
dec2n a, 16, s
print a; "=("; s; ")16"
end sub
sub dec2n(byval a, r, s)s = ""
while a > 0
x = a mod r
if x < 10 then s = x & s else s = chr(55 + x) & s
a = a \ r
wend
end sub
6樓:匿名使用者
這個大部分都做好了
你需要的話 可以幫你做
編寫程式,利用sub過程把任意一個十進位制整數n分別轉化為二進位制,八進位制,十六進位制數。
7樓:匿名使用者
private sub text1_change()
dim n
if len(text1) > 0 and isnumeric(text1) then
n = val(text1)
dec_to_bin n
dec_to_oct n
dec_to_hex n
else
text1 = ""
end if
end sub
sub dec_to_bin(byval dec)
label5.caption = ""
do while dec > 0
label5.caption = dec mod 2 & label5.caption
dec = dec \ 2
loop
end sub
sub dec_to_oct(byval dec)
label6.caption = ""
do while dec > 0
label6.caption = dec mod 8 & label6.caption
dec = dec \ 8
loop
end sub
sub dec_to_hex(byval dec)
dim a as string
label7.caption = ""
do while dec > 0
a = cstr(dec mod 16)
select case a
case "10": a = "a"
case "11": a = "b"
case "12": a = "c"
case "13": a = "d"
case "14": a = "e"
case "15": a = "f"
end select
label7.caption = a & label7.caption
dec = dec \ 16
loop
end sub
vb程式。將一個十進位制數分別轉換成二,八,十六進位制數。 5
8樓:匿名使用者
'vb程式。將一個十進位制
數分別轉換成二,八,十六進位制數。
private sub text1_change()'tonkeys qq 58507961
'十進位制 to 二進位制
a% = val(text1.text)
tmp = ""
dotmp = (a mod 2) & tmpif a < 2 then exit doa = a \ 2
loop
text2.text = tmp
'十進位制 to 八進位制
a% = val(text1.text)
tmp = ""
dotmp = (a mod 8) & tmpif a < 8 then exit doa = a \ 8
loop
text3.text = tmp
'十進位制 to 十六進位制
a% = val(text1.text)
text4.text = hex(a)
end sub
編寫function函式過程,能夠實現十進位制轉換為二進位制、八進位制、十六進位制。(用vb做)
9樓:
供參考……
#include "stdafx.h"
#include "iomanip.h"
void d10to2_8_16(int i,char radix)void main(void)
編寫程式**:定義一個函式過程實現十進位制數轉換成二進位制數、八進位制數、十六進位制數的功能。 80
10樓:
#include "stdio.h"
#include "stdlib.h"
int main()
用VB程式編寫過程來計算1 2 3 4100的值
private sub command1 click dim sum as integer 定義變數sum,i為整形dim i as integer sum 0 給sum賦值 for i 1 to 100 for迴圈sum sum i 迴圈過程每次給sum加一next i print sum 輸出s...
VB題,窗體中有命令按鈕,編寫如下程式求過程,謝
請按以下步驟操作 1.開啟vb新建一個工程,儲存好 2.窗體上畫一個一個命令按鈕command1 命令按鈕標題 隱藏 一個標籤label1,標籤最好打幾個字 3.雙擊命令按鈕進入 編輯器 1.寫如下 ifcommand1.caption 隱藏 then label1.visible false co...
vb編寫用於求隨機數的程式,vb編寫一個用於求隨機數的程式
private sub form mousedown button as integer,shift as integer,x as single,y as single dim i as integer,f as doublerandomize if button vbkeylbutton the...