1樓:匿名使用者
1,private sub form_click()
dim a(1 to 50) as integer
dim sum as long
dim sumdel as long
for i = 1 to 50
a(i) = i ^ 2
sum = sum + a(i)
next
for i = 1 to 50
if a(i) mod 7 = 0 or a(i) mod 13 = 0 then
sumdel = sumdel + a(i)
end if
next
print "所求的和為:" & sum - sumdel
end sub
3,private sub form_click()
i = asc(inputbox("請輸入字元", "輸入框"))
if i >= 48 and i <= 57 then
msgbox "你輸入的是數字字元"
elseif (i >= 65 and i <= 90) or (i >= 97 and i <= 122) then
msgbox "你輸入的是字母字元"
else
msgbox "你輸入的是其它字元"
end if
end sub
4,'通用的排序過程
private sub rank(n as integer, a() as long)
for i = 1 to n - 1
imin = i
for j = i + 1 to n
if a(j) > a(imin) then imin = j
next j
if imin <> i then t = a(i): a(i) = a(imin): a(imin) = t
next i
end sub
private sub form_click()
dim s(1 to 3) as long
for i = 1 to 3
s(i) = val(inputbox("輸入第i個資料"))
next
call rank(3, s())
for i = 1 to 3
list1.additem s(i)
next
end sub
5,private sub form_click()
dim m as long
dim n as long
m = val(inputbox("請輸入m的值", "輸入框"))
n = val(inputbox("請輸入n的值", "輸入框"))
print "最大公約數為:" & max公約數(m, n)
end sub
function max公約數(a as long, b as long) '求出兩個數的最大公約數
dim x as long, y as long, k as long
x = iif(a >= b, a, b) 'x存入最大值
y = iif(a <= b, a, b) 'y 存入最小值
do '輾轉相除法
k = x mod y: if k = 0 then exit do
x = y: y = k
loop
max公約數 = y
end function
6,'通用宣告
option explicit
dim m as integer, n as integer
private sub form_load()
don = val(inputbox("n:"))
m = val(inputbox("m:"))
loop until n <= m
end sub
private function jc(byval x as integer) as double
dim i as integer
dim result as double
result = 1
for i = 1 to x
result = result * i
next i
jc = result
end function
private sub command1_click()
dim doufact as double
doufact = jc(m) / (jc(n) * jc(m - n))
text1.text = str(doufact)
end sub
2樓:匿名使用者
1.dim sum as long
dim i as integer
for i= 1 to 50
if i mod 7<>0 and i mod 13<>0 thensum=sum+i^2
end if
next i
3樓:匿名使用者
1,dim s, a, n as integers = 0
a = 1
do until a >= 50
s = s + a ^ 2
a = a + 1
for n = 1 to 7
if a = 7 * n or a = 13 * n thendo while a = 7 * n or a = 13 * na = a + 1
loop
end if
next n
loop
label1.text = s
2,上課了,下次再給你。。呵呵。。。不好意思
4樓:昆明錦鯉設計
第四題(非條件句解法):仔細看看你的題目發現有點問題,是不是輸入三個數排序,按從大到小排序然後輸出。下面就是最簡便的方法(vb2005):
dim x,y,z as double
x=val(textbox1.text)
y=val(textbox2.text)
z=val(textbox3.text)
dim a() as double =
array.sort(a)
msgbox("三個數從大到小排序是:"&a(0)&"、"&a(1)&"、"&a(2))
*****===
條件句的話要判斷很多句啊。慢慢寫就出來了。。
100分!幾道VB程式設計題!急用
1 編寫過程計算1 1 2 1 3 1 100定義函式 s u 1 u 設定迴圈 for n 1 to 50 step 1結果 r r s n next n 輸出結果 r 這是關鍵步驟,怎麼寫看你 要麼用極限算,這是高3的數學方法!第2個直接用記事本 打出來正三角形,然後在前面加列印函式!試題二 這...
請各位大俠幫忙解決些VB題
1 題目不是很清楚,能否重述 2 1 if法 private sub form click dim fs as single dim cj as string fs inputbox 請輸入分數 分數轉化 if fs 100 then if fs 90 then cj a等 elseif fs 80...
vb程式設計3,急急急,各位高手幫幫忙啊
vb6.0的引數 private sub command1 click 確定鍵static a as integer text2.passwordchar if text1.text 123 or text2.text abc then 使用者名為123,密碼為abc a a 1 a msgbox ...