用VB設計程式時出現子程式或函式未定義是什麼原因

2022-05-07 05:25:28 字數 3490 閱讀 8480

1樓:岔路程式緣

這樣子改:

private type student

sno as string * 7

sname as string * 9

grade as integer

end type

option base 1

dim i as integer, j as integer

dim stu(10) as student, t as student

private sub command1_click()

for i = 1 to 9

for j = 1 to 10 - i

if stu(j).grade < stu(j + 1).grade then

t = stu(j)

stu(j) = stu(j + 1)

stu(j + 1) = t

end if

next j

next i

for i = 1 to 10

print stu(i).sno, stu(i).sname, stu(i).grade

next i

end sub

private sub form_load()

dim a(), b(), c()

a = array("tom", "jerry", "lisa", "tony", "bob", "jack", "july", "rose", "robert", "peter")

b = array("05070301", "05070302", "05070303", "05070304", "05070305", "05070306", "05070307", "05070308", "05070309", "05070310")

c = array(87, 53, 96, 88, 70, 63, 91, 72, 78, 67)

for i = 1 to 10

stu(i).sno = a(i)

stu(i).sname = b(i)

stu(i).grade = c(i)

print stu(i).sno, stu(i).sname, stu(i).grade

next i

end sub

ok了,已經執行過了。

2樓:匿名使用者

幫你改了一下:

option explicit

private type student

sno as string * 7

sname as string * 9

grade as integer

end type

option base 1

dim stu(10) as student, a, b, c, i as integer

private sub command1_click()

dim t as student, j

for i = 1 to 9

for j = 1 to 10 - i

if stu(j).grade < stu(j + 1).grade then

t = stu(j)

stu(j) = stu(j + 1)

stu(j + 1) = t

end if

next j

next i

for i = 1 to 10

print stu(i).sno, stu(i).sname, stu(i).grade

next i

end sub

private sub form_load()

a = array("tom", "jerry", "lisa", "tony", "bob", "jack", "july", "rose", "robert", "peter")

b = array("05070301", "05070302", "05070303", "05070304", "05070305", "05070306", "05070307", "05070308", "05070309", "05070310")

c = array(87, 53, 96, 88, 70, 63, 91, 72, 78, 67)

for i = 1 to 10

stu(i).sno = a(i)

stu(i).sname = b(i)

stu(i).grade = c(i)

print stu(i).sno, stu(i).sname, stu(i).grade

next i

end sub

3樓:匿名使用者

option base 1

private type student

sno as string * 7

sname as string * 9

grade as integer

end type

dim stu(10) as student '宣告在這裡,對所有過程都有作用

private sub command1_click()

for i = 1 to 9

for j = 1 to 10 - i

if stu(j).grade < stu(j + 1).grade then

t = stu(j).grade

stu(j).grade = stu(j + 1).grade 『這裡少寫了

stu(j + 1).grade = t

end if

next j

next i

for i = 1 to 10

print stu(i).sno, stu(i).sname, stu(i).grade

next i

end sub

private sub form_load() 『這裡不要定義區域性變數

a = array("tom", "jerry", "lisa", "tony", "bob", "jack", "july", "rose", "robert", "peter")

b = array("05070301", "05070302", "05070303", "05070304", "05070305", "05070306", "05070307", "05070308", "05070309", "05070310")

c = array(87, 53, 96, 88, 70, 63, 91, 72, 78, 67)

for i = 1 to 10

stu(i).sno = a(i)

stu(i).sname = b(i)

stu(i).grade = c(i)

print stu(i).sno, stu(i).sname, stu(i).grade

next i

end sub

4樓:匿名使用者

**最前面加option explicit 自己就可以實現差錯!

vb的sub子程式怎麼用,關於vb的sub子過程的定義問題!

建立sub過程 1 定義sub過程 語句結構如下 static private public sub 過程名 引數列表 語句塊 exit sub 語句塊 endsub 引數列表指明瞭呼叫時傳送給過程的引數的型別和個數,每個引數的格式為 byval 變數名 as 資料型別 如果加上byval則表明該引...

請問C 到底是做題還是設計程式?

當然是設計程式了,做題只是學習中的過程,最終當然是設計程式了。std是乙個類 輸入輸出標準 它包括了cin成員和cout成員,using name space std 以後才能使用它的成員。include中不存在類std,但是他又cin,out的相關函式,不需要使用命名空間了。而第二種標準 incl...

用eclipse寫servlet程式時,是不是不會自動生成w

最新版bai本的eclipse配置duservlet不會生成web.xml檔案。eclipse配置的是zhitomcat7,那麼建dao立web專案是沒有web.xml檔案的專。web.xml檔案是用屬來配置 歡迎頁 servlet filter等的。當你的web工程沒用到這些時,你可以不用web....