當前位置:編程學習大全網 - 編程軟體 - VB編程:單擊command1,則隨機產生10個0~100之間的數值,將之保存到壹維數組中a中,同時顯示在text1中。

VB編程:單擊command1,則隨機產生10個0~100之間的數值,將之保存到壹維數組中a中,同時顯示在text1中。

dim a(9) as integer

private sub command1_click()

dim i as integer

randomize

for i=0 to 9

a(i)=int(rnd*101)

text1.text=text1.text & a(i) & ","

next i

end sub

private sub command2_click()

dim b as integer,i as integer,c as boolean

b=val(inputbox("請輸入壹個數字"))

c=false

for i=0 to 9

if b=a(i) then

c=true

exit for

end if

next

if c=false then text2.text="不存在於數組中" else text2.text="在數組中的位置=" & i+1

end sub

  • 上一篇:嵌入式工控電腦的技術
  • 下一篇:美女擺牌遊戲推薦
  • copyright 2024編程學習大全網