VB自定義型別陣列及應用,一道VB自定義型別陣列的應用題 高人幫忙給一下程式碼 急! 謝謝了!!

時間 2022-02-03 11:00:09

1樓:玫瑰為你盛開

控制項按要求自己加哈,不要給控制項改名,不要做任何屬性設定,程式**如下:

private type employeeinfo

serial as string

name as string

wage as single

end type

dim work(1 to 5) as employeeinfo

private sub command1_click()

static n as integer

if trim(text1.text) = "" or trim(text2.text) = "" or trim(text3.

text) = "" then msgbox "新增時,文字框均不得留空!": exit sub

n = n + 1

work(n).serial = text1.text

work(n).name = text2.text

work(n).wage = val(text3.text)

text1.text = ""

text2.text = ""

text3.text = ""

me.caption = "已新增" & n & "位職工的資訊"

if n = 5 then

command2.enabled = true

command1.enabled = false

me.caption = "請按職工工資排序"

msgbox "5位職工的資訊已新增完畢!"

end if

end sub

private sub command2_click()

dim i as integer, j as integer, t as single, temp as string

for i = 1 to 4

for j = i + 1 to 5

if work(i).wage < work(j).wage then

t = work(i).wage: work(i).wage = work(j).wage: work(j).wage = t

temp = work(i).serial: work(i).serial = work(j).serial: work(j).serial = temp

temp = work(i).name: work(i).name = work(j).name: work(j).name = temp

end if

next

next

picture1.cls

for i = 1 to 5

picture1.print work(i).serial, work(i).name, work(i).wage

next

end sub

private sub form_load()

label1.caption = "職工號"

label2.caption = "姓名"

label3.caption = "工資"

text1.text = ""

text2.text = ""

text3.text = ""

command1.caption = "新增"

command2.caption = "排序"

command2.enabled = false

me.caption = "請新增第1位職工資訊"

end sub

編寫程式,在主函式中輸入整型陣列,在自定義函式invert中逆序放置陣列中的所有元素,並將結果

夜襲者 include void invert int a,int s void main s sizeof a sizeof a 0 s表示陣列長度 printf now,the array is n for i 0 i 10 i printf n invert a,s 倒置陣列 printf n...

c 自定義類的物件做函式引數為什麼一定要用引用傳值

函式引數有直接變數 如int char double等 型別 指標型別和引用型別。如果引數是變數,傳遞方式是傳值,就是將實參的值複製 複製,意味著空間消耗和時間消耗 到 棧 空間中。如果引數是指標,傳遞方式是傳址,需將指標複製 同樣也消耗空間和時間,對於陣列而言,只需儲存陣列首地址 到 棧 空間中。...

VB題 定義具有元素的一維陣列,並對其隨機賦值,然後求出其中元素值為奇數的元素的和

程式如下,用了二個列表框,乙個放隨機的20個數,另乙個放為奇數的,結果在視窗上列印出來。dim aa 20 as integerrandomize 隨機數初始化ss 0 for i 1 to 20 aa i rnd 1 1000 0.5 隨機產生乙個數,轉換為整數 list1.additem aa ...