vb高手幫忙

2022-07-28 14:40:16 字數 1224 閱讀 9954

1樓:匿名使用者

已幫你修改:

private sub form_click()dim temp as integer, a(1 to 100) as integer, x as integer

for i = 1 to 100

a(i) = int(rnd * 900 + 100)next i

for i = 1 to 99

k = i

for j = i + 1 to 100

if a(j) < a(k) then k = jnext j

temp = a(i): a(i) = a(k): a(k) = temp

next i

for i = 1 to 100

print a(i);: if i mod 5 = 0 then print

if a(i) mod 3 = 0 thenform1.forecolor = vbredelse

form1.forecolor = vbblackend if

next i

end sub

2樓:

private sub form_click()

dim temp as integer, a(100) as integer, x as integer

randomize timer '這裡最好初始化rnd,否則每次生成都是同樣的數

for i = 1 to 100

a(i) = int(rnd * 900 + 100)

next i

for i = 1 to 99

k = i

for j = i + 1 to 100

if a(j) < a(k) then k = j

next j

temp = a(i): a(i) = a(k): a(k) = temp

next i

for i = 1 to 100

print a(i);: if i mod 5 = 0 then print

if a(i) mod 3 = 0 then '你原來的if語句放在for語句外了,因此i是上回的值:101,所以超出了標界

form1.forecolor = vbred

else

form1.forecolor = vbblack

end if

next i

end sub

vb高手請進,vb高手請進

option 的意思是二選一或多選一,當一組option存在時,必定有乙個會被自動選上,當只有乙個時,這個按鈕肯定會被選上,即使你將其value設定為false都沒有用.按你的意思,我推薦你用checkbox.這樣就會達到你的要求了 類似的問題我也遇到過。我是這樣解決的 假如你要使用的控制項名為op...

請高手幫忙解決VB的list問題

新建工程,2個窗體.form1是主窗體,也就是實現你這些功能的 放置的地方.而form2就是你想彈出窗體的樣子 如果你想彈出來的窗體都是這個樣子的話 form1的 雙擊列表項,開啟對應個數的form2 sub newform s dim a as form2 set a new form2 a.ca...

vb如何識別非數字字元!高手幫幫忙

private sub text1 change if isnumeric text1.text false then msgbox 輸入有非數字字元 vbcritical vbexclamation,系統提示 exit sub else if instr text1.text,0 or instr...