1樓:壬捷
private sub form_click()dim i%,j%,s%
i=1,j=0
do while s<=2000
j=i+j
s=s+j
i=i+1
loop
print "n=";i
print "s=";s
end sub
有點不記得了
大概是這樣的
你自己除錯一下哈!
2樓:匿名使用者
private sub form_click()m = 1
n = 0
don = n + 1
if n > m then
n = 1
m = m + 1
end if
s = s + n
print n;
loop until s > 2000
print s; n
end sub
3樓:慕葉孤丹
小學要考程式設計嗎,這麼牛逼的學校。我們連world都沒教完
急求!一道vb程式設計題 謝謝!
4樓:
private sub procmin(a() as integer, byval amin as integer)
dim i%, amin0%
for i = lbound(a) to ubound(a)print a(i);
amin0 = a(lbound(a))
if a(i) < amin0 then amin = a(i)next i
print "amin="; amin
end sub
private sub command1_click()dim a(1 to 10) as integer, i% ', amin0%
for i = 1 to 10
a(i) = int(501 * rnd + 300)next i
call procmin(a(), amin)end sub
5樓:匿名使用者
主程式dim a(10) as integerrandomize
for i = 0 to 9
a(i) = int((800 - 300 + 1) * rnd + 300)
next
procmin(a())
--子函式
function procmin(a() as integer) as integer
dim min as integer
min = a(0)
for i = 1 to 9
if min > a(i) then
min = a(i)
end if
next
procmin = min
end function
求一道vb程式設計題,高手請進....謝謝!!!
6樓:匿名使用者
private sub command1_click()
'第一種演算法,全部迴圈了一遍,所以速度慢
dim stmp as string
dim sresult1 as string
dim sresult2 as string
dim ilen as integer
dim i as integer
if not isnumeric(me.text1.text) then
msgbox "請輸入乙個數字"
exit sub
end if
ilen = len(me.text1.text)
sresult1 = 10 ^ ilen
for i = 1 to ilen
stmp = left(me.text1.text, i - 1) & right(me.text1.text, ilen - i)
if clng(stmp) < clng(sresult1) then
sresult1 = stmp
sresult2 = mid(me.text1.text, i, 1)
end if
next
msgbox "去除該數字: " & sresult2 & " 得到的結果最小,結果是 " & sresult1
end sub
private sub command2_click()
'第二種演算法,速度快,輸入的數字位數越多,效果越明顯
dim stmp1 as string
dim stmp2 as string
dim ilen as integer
dim i as integer
ilen = len(me.text1.text)
for i = 1 to ilen
stmp1 = mid(me.text1.text, i, 1)
stmp2 = mid(me.text1.text, i + 1, 1)
if stmp2 = "" then stmp2 = -1
if cint(stmp1) > cint(stmp2) then
msgbox "去除該數字: " & stmp1 & " 得到的結果最小,結果是 " & left(me.text1.
text, i - 1) & right(me.text1.text, ilen - i)
exit sub
end if
next
end sub
7樓:
沒有必要短時間內重複提問
求解一道簡單的vb程式設計題
8樓:
錢江化工 的程式執行結果是正確的( s=s+3^i)。
但我不建議樓主這樣程式設計。因為他的效率太低,含有大量的重複計算。例如算了3的平方,再算3的四次方,然要從頭開始。實際上完全可以在前乙個的基礎上乘以3就行了。
**如下:
private sub command1_click()dim 和 as long,單項 as long,項數 as integer
和=1單項=1
for 項數=1 to 10
單項=單項*3
和=和+單項
next 項數
?"結果是";和
end sub
9樓:
dim s, i
for i=0 to 10
s=s+3^i
next
msgbox(s)
一道有關vb程式設計的題目
10樓:火星飛人
private sub form_load()
show
label1.autosize = true
label1.caption = str(time())
label1.top = val(form1.height) / 2 - val(label1.height) / 2
label1.left = val(form1.width) / 2 - val(label1.width) / 2
command1.caption = "放大"
end sub
private sub command1_click()
label1.fontsize = val(label1.fontsize) * 3
label1.caption = str(time())
label1.top = val(form1.height) / 2 - val(label1.height) / 2
label1.left = val(form1.width) / 2 - val(label1.width) / 2
end sub
11樓:
label1.caption = now
now就是當前系統時間
一道vb程式設計題目 求大佬解答!!!
12樓:聽不清啊
private sub command1_click()dim x as integer, y as integerx = inputbox("請輸入乙個正整數:")t = x
y = 0
doy = y * 10 + t mod 10t = t \ 10
loop while t > 0
msgbox x & " 的逆序數是: " & yend sub
求解一道高中vb題目!
13樓:匿名使用者
private sub form_click()dim i as integer
dim s as integer
s = 1
for i = 1 to 9
s = (s + 1) * 2
next i
print "s="; s
end sub
是1534個 迴圈9次。因為第十天已經剩下1個 就沒再吃了 樓上那位 han4422951 - 都司 七級 初始值s為1 你還用除2 真服你了。~
14樓:匿名使用者
dim a%, s%, i%
a = 1 : s = 0
for i = 1 to 9
s = a * 2 + 2
a = s
next
print "s="; s
你拿筆自己演算一下就會知道,每一天的桃子數總是第二天的兩倍多兩個,第四行**就是根據每天的桃子數算出前一天的桃子數,然後再根據前一天的桃子數算出再前一天的桃子數,這個迴圈不能迴圈十次,因為迴圈了九次後已經是最初一天的桃子數了!最後的答案是1534
15樓:who絕版笨_我
這不是數學題嗎?
dim taozi as long
taozi=1
for i=1 to 10
taozi=taozi+1
taozi=taozi*2
next i
msgbox "桃子總數: " & trim(taozi)
16樓:匿名使用者
private sub form_clickdim n%,i%
x=1print"第10天的桃子數為:1個"
for i= 9 to 1 step-1
x=(x+1)*2
print"第";i;"天的桃子數為:";x;"個"
next i
end sub
急求!vb程式設計題目
dim m as integer,n as integerprivate sub command1 click m val inputbox 輸入正整數 n val inputbox 輸入正整數 if n m 0 then msgbox 兩數任何乙個數都不能為0 exit sub end if en...
急求!一道VB程式設計題謝謝,10道VB題 急求答案!!!謝謝高手了
private sub procmin a as integer,byval amin as integer dim i amin0 for i lbound a to ubound a print a i amin0 a lbound a if a i amin0 then amin a i ne...
求一道VB題目急求
按照你的意思,相當於把陣列按正序和反序分別輸出。編寫程式如下 dim a 1 to 20 as integer,i as integer for i 1 to 20 a i inputbox 請輸入第 str i 個數 next i for i 1 to 20 print a i next i pr...