1樓:匿名使用者
dim a(10), x as integerdim str as string = ""
dim di as boolean = truedim n as integer
for i = 1 to 10
dodo
n = int(rnd() * 200 + 300)loop until issushu(n)if i > 1 then
for x = 1 to i - 1
if a(x) = n then
msgbox(str & " 最新 " & n)di = false
end if
next
end if
loop until di = true
a(i) = n
str = str & a(i) & " "
randomize(10)
next
for i = 1 to 10
for j = 1 to 10 - i
if a(j) > a(j + 1) thenx = a(j + 1)
a(j + 1) = a(j)
a(j) = x
end if
next j
next i
for i = 1 to 10
str = str & a(i) & " "
next
textbox6.text = str
2樓:聽不清啊
private sub command1_click()print "300-500之內的10個素數:"
for i = 300 to 500
if prime(i) then
print i;
n = n + 1
if n mod 5 = 0 then printif n = 10 then exit forend if
next i
end sub
function prime(n)
prime = false
for i = 2 to sqr(n)
if n mod i = 0 then exit functionnext i
prime = true
end function
VB程式設計,找出所有的「水仙花數」
這個程式在vb中與vc中是有些些不同的,因為vc中當定義每位為整型時,它不會有四捨五入規則的,而vb中則不同。比如 vc中 153 100 10 1,而vb中它算出來的為2,所以注意這個就可以了。在vb中就先從個位判斷,是否超過或等於5,是的話就讓它減去0.5,不是的話直接操作。vb中程式如下 乙個...
vb程式設計,vb程式設計
private sub command1 click dim obj as object,mymouse as integer if list1.selcount 0 and list2.selcount 0 then for each obj in me.controlsif obj.name l...
vb程式設計題目,VB程式設計試題
您的第乙個問題 text1.text 輸入的數 就是 變數 在文字框裡不是什麼數都可以輸入麼?這就是常量啊!您的第二個問題 當然是寫50 應為val把50轉化了數值 為了方便你理解 我舉兩個例子吧 if val text1.text 60 thenprint pass else print nopa...
VB程式設計題目,VB程式設計題?
private sub form load text1.fontsize 10 end sub private sub command1 click text1.fontsize 10 int rnd 3 1 end sub private sub command2 click text1.font...
VB程式設計題,Vb程式設計題,
開頭你自己寫 中間過程是這樣的!int s,sum s 0 sum 0 for i 1 to 10 for j i 1 to 10 s j i next j end sum s sum next i end a 1 for i 1 to 10 a a i s s a next i label1.ca...