1樓:匿名使用者
private sub command1_click()dim str as string
dim arr(1 to 20) as stringfor i = 20 to 1 step -1arr(i) = inputbox("請輸入第 " & (21 - i) & "個數")
str = str & arr(i) & " "
next
print "交換前: " & vbcrlf & strprint "交換後: "
for i = 1 to ubound(arr)print arr(i) & " ";
next
end sub
2樓:匿名使用者
private sub command1_click()dim a(1 to 20)
for i = 1 to 20
a(i) = val(inputbox("請你輸入第" & i & "個數"))
next i
print "交換前的數為"
for i = 1 to 20
print a(i);
if i mod 10 = 0 then printnext i
for i = 1 to 10
b = a(i): a(i) = a(21 - i): a(21 - i) = b
next i
print "交換後的數為"
for i = 1 to 20
print a(i);
if i mod 10 = 0 then printnext i
end sub
private sub form_load()me.autoredraw = true
end sub
3樓:匿名使用者
dyeb @@@cfsx 19d si
4樓:古龍珈藍玉
vb程式設計的輸入編寫的時候要注意寫作速度,元素,v的輸入
vb程式設計:某陣列中有10個元素,元素的值由鍵盤輸入,要求將前5個元素與後5個元素對換,
5樓:良陣
dim a() as integer 』原來的陣列dim b() as integer '換後的陣列dim i as integer
for i=0 to 4
b(i)=a(9-i)
b(9-i)=a(i)
next i
你要怎麼樣輸入輸出資料?是一個一個輸,輸10次還是一個textbox中輸入10個數中間用空格隔開
輸出,是在另一個textbox中顯示還是msgbox彈出來顯示
6樓:匿名使用者
private sub command1_click()dim a(1 to 10) as integerdim i as integer, tmp as integerfor i = 1 to 10
a(i) = inputbox("input number")print a(i);
next
for i = 6 to 10
tmp = a(i - 5)
a(i - 5) = a(i)
a(i) = tmp
next
for i = 1 to 10
print a(i);
next
7樓:匿名使用者
直接伸手啊,把你會的**拿出來,我幫你發言
(1/2)用vb程式程式設計:從鍵盤上輸入10個整數,並放入一個一維陣列中,然後將其前5個元素與後5個元素對換... 40
8樓:司寇忻
private sub command1_click()
dim tmp as string, tmp1 as string, a() as string
me.cls
tmp = text1.text
if not isnumeric(tmp) then goto outerr
a = split(tmp, ",")
if ubound(a) <> 9 then msgbox "請輸入十個整數!", vbinformation, "提示": exit sub
for i = 0 to 4
tmp1 = a(i)
a(i) = a(9 - i)
a(9 - i) = tmp1
next i
for i = 0 to 9
if int(val(a(i))) = val(a(i)) then
me.print a(i) & ",";
else
me.print a(i) & "(不是整數)";
end if
next i
exit sub
outerr:
a = split(tmp, ",")
for i = 0 to ubound(a)
if not isnumeric(a(i)) then me.print vbcrlf & a(i) & "不是整數"
next i
end sub
private sub text1_change()
dim a() as string
a = split(text1.text, ",")
if a(ubound(a)) <> "" then label1.caption = "共輸入:" & ubound(a) + 1 & "個數"
end sub
9樓:櫻雪殤
option base 1
private sub form_click()dim a%(10)
for i = 1 to 10
a(i) = inputbox("輸入第" & i & "個元素值:")
print a(i);
next i
for i = 1 to 5
temp = a(i): a(i) = a(11 - i): a(11 - i) = temp
next i
for i = 1 to 10
print a(i);
next i
end sub
用vb編寫求元素的一維陣列A,使用INPUTBOX函式賦值,輸出最小元素的值及其下標
尤在尤存 一樓有問題.dim a 19 as double for i 0 to 19 a i inputbox 請輸入一個數 next dim min1 as double 記錄最小值dim min2 as integer 記錄下標min1 a 0 min2 0 要賦初值for i 1 to 19...
c程式 將陣列的所以元素列印出來
劉培鑫 你的陣列是string型別嗎,是的話 如下 string str new string foreach string sss in str for int i 0 i 注 array是int float string 等基本型別的陣列.如果是自定義型別則輸出type.tostring 引入一...
vb用氣泡排序法實現對陣列中含有元素隨機
這個要動態演示排序過程麼?還是直接顯示排序的結果? private sub command1 click dim a 1 to 10 i j,s as integerrandomize for i 1 to 10 隨機10個產生1 100的整數 a i int rnd 100 1next i for...