版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、實驗aa1private sub command1_click() label3 = text1end suba2private sub form_load() timer1.interval = 0end subprivate sub command1_click() 自動 timer1.interval = 200end subprivate sub command2_click() 手動 timer1.interval = 0 call mymoveend subprivate sub timer1_timer() call mymoveend subsub mymove() label
2、1.move label1.left - 50 if label1.left 0 then label1.left = form1.widthend suba3private sub form_click() text1 = val(text1) + 1end subprivate sub form_load() text1 = 0end suba4private sub form_click() caption = 單擊窗體,改變圖片 picture = loadpicture(app.path + n_015.bmp) print 歡迎使用vbend subprivate sub form
3、_dblclick() cls caption = 雙擊窗體,卸去圖片 picture = loadpicture() end subprivate sub form_load() caption = 裝入窗體 picture = loadpicture(app.path + n_016.bmp) print 裝入圖end subprivate sub form_resize() 該事件的作用窗體始終與圖一樣大 caption = 窗體大小不變 form1.width = 260 * 16 260是tongji-2.bmp圖的寬度,象素單位 form1.height = 260 * 16 +
4、200 260是圖的高度,象素單位,200是窗體的標(biāo)題欄高度end suba5sub command1_click() text1.fontname = 隸書 text1.fontsize = 25end subsub command2_click() text2.text = text1.seltext text2.fontname = text1.fontname text2.fontsize = text1.fontsizeend sub實驗bb1private sub command1_click() text2 = format(5 / 9 * (val(text1) - 32),
5、0.00)end subprivate sub command2_click() text1 = format(9 / 5 * val(text2) + 32, 0.00)end sub或private sub command1_click() dim f!, c! 聲明兩個變量 f = val(text1) c = 5 / 9 * (f - 32) text2 = format(c, 0.00) 保留兩位小數(shù)end subprivate sub command2_click() dim ff!, cc! 聲明兩個變量 cc = val(text2) ff = 9 / 5 * cc + 32
6、text1 = format(ff, 0.00) 保留兩位小數(shù)end subb2private sub command1_click() label2 = format(val(text1) * val(text1) * 3.14, 0.00)end subprivate sub command2_click() label3 = format(val(text1) * 3.14 * 2, 0.00)end subprivate sub text1_lostfocus() if not isnumeric(text1.text) then msgbox 輸入有非數(shù)字字符,請重新輸入, , 警告
7、 text1.text = text1.setfocus end ifend sub或private sub command1_click() label2 = format(val(text1) * val(text1) * 3.14, 0.00)end subprivate sub command2_click() label3 = format(val(text1) * 3.14 * 2, 0.00)end subprivate sub text1_keypress(keyascii as integer) if keyascii = 13 then if not isnumeric(t
8、ext1.text) then text1.text = end if end ifend subb3private sub command1_click() n = int(log(2) / log(1.008) + 1) label1 = n & 年后人數(shù)超過26億end subb4private sub command1_click() dim x, dx, cd x = text1.text dx = ucase(x) cd = len(x) print 大寫字母為:; dx print 字符串長度為:; cdend subb5private sub command1_click()
9、text1 = int(rnd * 900 + 100)end subprivate sub command2_click() dim x%, x1%, x2%, x3% x = val(text1) x1 = x mod 10 分離出的個位數(shù) x2 = (x mod 100) 10 分離出的十位數(shù) x3 = x 100 分離出的百位數(shù) label1 = x1 * 100 + x2 * 10 + x3end subb6private sub form_click() label1 = left(text1, 11) label2 = mid(text1, 12, 6) label3 = rig
10、ht(text1, 5)end subb7private sub command1_click() print for i = 1 to 5 print tab(15 - i * 2); string(2 * i - 1, ); spc(18 - 4 * (i - 1); string(2 * i - 1, ) next iend subprivate sub command2_click() clsend sub進(jìn)一步要求:private sub command1_click() print for i = 1 to 5 print tab(15 - i * 2); string(2 * i
11、 - 1, ); string(10 - (2 * i - 1), ); string(2 * i - 1, ) next iend subprivate sub command2_click() clsend subb8private sub form_click()x = val(inputbox(輸入一正實數(shù), 計算, 0)pf = format(x * x, 0.000)pfg = format(sqr(x), 0.000)lf = format(x * x * x, 0.000)lfg = format(x (1 / 3), 0.000)print 平方為:; pf; space(5
12、); 平方根為:; pfg; space(5); 立方為:; lf; space(5); 立方根為:; lfgend sub實驗cc1private sub form_click()dim x!, y!x = val(inputbox(輸入x的值)if x 1000 theny = xelseif x 2000 theny = 0.9 * xelseif x 3000 theny = 0.8 * xelsey = 0.7 * xend ifprint yend subc2private sub form_click()dim x!, y!x = val(inputbox(輸入上網(wǎng)時間)if x
13、 10 theny = 30elseif x 150 theny = 150end ifprint yend subc3private sub command1_click() dim x!, y!, z! x = inputbox(input x) y = inputbox(input y) z = inputbox(input z) print x y z print 排序前; x; ; y; ; z if x y then t = x: x = y: y = t if x z then t = x: x = z: z = t if y z then t = y: y = z: z = t
14、 print 排序后 & x & & y & & zend subprivate sub command2_click() dim x!, y!, z! x = inputbox(input x) y = inputbox(input y) z = inputbox(input z) print x y z print 排序前; x; ; y; ; z if x y then t = x: x = y: y = t if y z then t = y: y = z: z = t if x a(i + 1) thenz = a(i + 1)a(i + 1) = a(i)a(i) = zend i
15、fnext ipicture2.print a(0)picture2.print a(1)picture2.print a(2)end subc5private sub text2_lostfocus() dim m%, n%, y% m = val(text1) n = val(text2) if n mod 2 0 then msgbox (腳數(shù)必定為偶數(shù)) text2 = text2.setfocus else y = n / 2 - m if y 0 then text4 = format(-b + sqr(de) / t, 0.00) text5 = format(-b - sqr(
16、de) / t, 0.00)else text4 = format(-b / t, 0.00) & + & format(sqr(abs(de) / t, 0.00) & i text5 = format(-b / t, 0.00) & - & format(sqr(abs(de) / t, 0.00) & iend ifend subprivate sub command2_click()text1 = text2 = text3 = text4 = text5 = end subc7private sub text3_lostfocus() select case trim(text3)
17、case + text4 = val(text1) + val(text2) case - text4 = val(text1) - val(text2) case * text4 = val(text1) * val(text2) case / if val(text2) = 0 then msgbox 分母為零,重新輸入 text2 = text2.setfocus else text4 = val(text1) / val(text2) end if end selectend subc8private sub text1_lostfocus() select case trim(tex
18、t1) case 1 text2 = monday case 2 text2 = tuesday case 3 text2 = wednesday case 4 text2 = thursday case 5 text2 = friday case 6 text2 = saturday case 7 text2 = sunday case is 7, is 7 or text1 1 then msgbox 數(shù)字為17,重新輸入 text1 = text1.setfocuselse text2 = choose(text1, monday, tuesday, wednesday, thursda
19、y, friday, saturday, sunday)end ifend sub實驗dd1private sub form_click() for i = 1 to 9 print tab(10 - i); string(2 * i - 1, trim(str(i) next iend subd2private sub form_click() for i = 1 to 10 step 1 print tab(i); string(20 - 2 * i), chr(64 + i) next iend subd3private sub command1_click()dim s!, t!, i
20、&s = 1t = 1for i = 1 to 100000t = t + is = s + 1 / tif 1 / t 0.00001 then exit fornext iprint for結(jié)構(gòu); s, i; 項end subd4private sub command1_click()dim n&, pi#, i&n = inputbox(輸入n值)pi = 2for i = 1 to n pi = pi * (2 * i) / (2 * i - 1) * (2 * i) / (2 * i + 1)next iprint 當(dāng)n= & n & 時,pi=; piend subd5privat
21、e sub form_click() dim s!, t!, i!, a%, n% a = int(rnd * 9 + 1) n = int(rnd * 6 + 5) t = 0: s = 0 print a=; a, n=; n for i = 1 to n t = t * 10 + a s = s + t print t; next i print print s=; send subd6private sub command1_click()dim s as integers = 0for i = 1 to 9 for j = 0 to 9 for k = 0 to 9 s = i *
22、100 + j * 10 + k if s = i 3 + j 3 + k 3 then print s end if next k next jnext iend subprivate sub command3_click()formd6.hidemain.showend subd7private sub command1_click() dim a!, x0!, x1! a = 27 x0 = 2 i = 0 do i = i + 1 x1 = 2 * x0 / 3 + a / (3 * x0 * x0) if abs(x1 - x0) max then max = a(i) if a(i
23、) min then min = a(i) avg = avg + a(i) next i avg = avg / 10 print print max=; max; min=; min; avg=; avgend sube2private sub form_click() dim a a = array(56, 78, 98, 88, 76, 78) for i = 0 to 5 print string(a(i) 5, ); a(i) print next iend sube3dim a%(19)private sub command1_click()picture1.cls for i
24、= 0 to 19 a(i) = int(rnd * 101) picture1.print a(i); ; if (i + 1) mod 4 = 0 then picture1.print next iend subprivate sub command2_click()picture2.clsdim s(5 to 9) for i = 0 to 19 k = a(i) 10 select case k case 0 to 5 s(5) = s(5) + 1 case 9 to 10 90100分的人數(shù) s(9) = s(9) + 1 case 6 to 8 存放其他三個分?jǐn)?shù)段的下標(biāo)有規(guī)律,
25、根據(jù)k獲得 s(k) = s(k) + 1 end selectnext i for i = 5 to 9 if s(i) 0 then picture2.print s(; i; )的人數(shù)有 ; format(s(i), 0); 個 next iend sube4private sub command1_click()picture1.clsdim d%(1 to 10)for i3 = 1 to 10randomized(i3) = int(rnd * 91 + 10)next i3for i = 1 to 10for j = 1 to 10 - iif d(j) = 5 then msg
26、box (超過5門課程,不能再選) exit sub else list2.additem list1.text list1.removeitem list1.listindex end ifend sube8sub combo1_keypress(keyascii as integer) select case keyascii case 48 to 57, 13 case else keyascii = 0 end select if keyascii = 13 then combo1.additem combo1.text combo1.text = end ifend subpriva
27、te sub command1_click() dim min%, max% min = val(combo1.list(0) max = val(combo1.list(0) imin = 0 imax = 0 for i = 1 to combo1.listcount - 1 if val(combo1.list(i) max then imax = i max = combo1.list(i) elseif val(combo1.list(i) min then imin = i min = combo1.list(i) end if next i t = combo1.list(0)
28、combo1.list(0) = combo1.list(imin) combo1.list(imin) = t t = combo1.list(combo1.listcount - 1) combo1.list(combo1.listcount - 1) = combo1.list(imax) combo1.list(imax) = tend sube9private sub form_click() for i = 0 to screen.fontcount - 1 if asc(left(screen.fonts(i), 1) = 5 then msgbox (輸入人數(shù)超過數(shù)組聲明的個數(shù)
29、)else with a(n) .number = text1 .name = text2 .salary = text3 picture1.print a(n).number, a(n).name, a(n).salary print end with n = n + 1 text1 = text2 = text3 = end ifend sub private sub command2_click()dim t as clerk, i%, j%for i = 0 to n - 1 for j = i to n - 1 if a(i).salary a(j + 1).salary then
30、t = a(i): a(i) = a(j + 1): a(j + 1) = t end if next jnext ipicture1.clspicture1.print 工號 姓名 工資for i = 0 to n - 1 picture1.print a(i).number, a(i).name, a(i).salary printnext iend sub實驗ff1private sub form_click() dim a(1 to 10), amin, i% for i = 1 to 10 a(i) = -int(rnd * 101 + 300) print a(i); next i
31、 call s(a(), amin) print print min=; aminend subsub s(b(), min) dim i% min = b(lbound(b) for i = lbound(b) + 1 to ubound(b) if b(i) min then min = b(i) next iend subf2private sub command1_click() dim mm%, nn% mm = val(text1) nn = val(text2) picture1.print mm; tab(6); nn; tab(12); gcd(mm, nn)end subf
32、unction gcd%(byval m%, byval n%) if m n then t = m: m = n: n = t r = m mod n do while (r 0) m = n: n = r: r = m mod n loop gcd = nend functionf3dim x!private sub command1_click()print 調(diào)用標(biāo)準(zhǔn)函數(shù)sin的結(jié)果; sin(x)end subprivate sub command2_click()print 調(diào)用自定義函數(shù) mysin的結(jié)果; mysin(x)end subfunction mysin(x!) as
33、double dim i%, t!, s! t = x s = t i = 1 do while abs(t) 0.00001 t = -1 * t * x * x / (i + 1) * (i + 2) s = s + t i = i + 2 loop mysin = send functionprivate sub command3_click()x = inputbox(輸入要計算正弦函數(shù)的角度值x)x = x * 3.14 / 180end subf4private sub text1_keypress(keyascii as integer) if keyascii = 13 the
34、n if not isnumeric(text1) then msgbox 輸入非數(shù)字串,重新輸入 text1.text = text1.setfocus else if ish(text1) then picture1.print text1; else picture1.print text1 end if text1 = end if end ifend subfunction ish(ss as string) as boolean dim i%, ls% ish = true ss = trim(ss) ls = len(ss) for i = 1 to ls 2 if mid(ss
35、, i, 1) mid(ss, ls + 1 - i, 1) then ish = false exit function end if next iend functionf5function prime(byval m as integer) as booleanprime = truedim i%for i = 2 to m - 1if (m mod i) = 0 then prime = false: exit function 注意冒號和exit的范圍next iend functionprivate sub command1_click()n = 0for i = 6 to 100
36、 step 2for j = 3 to i 2if prime(j) thenif prime(i - j) thenlist1.additem i & = & j & + & i - jn = n + 1end ifend ifnext jnext ipicture1.print 6和100之間共有; n; 對素數(shù)和end subf6dim a%()private sub form_click() print 1000以內(nèi)的完數(shù)為: for i = 1 to 1000 if isws(i) then print i; =1; for j = 1 to ubound(a) print +; a
37、(j); next j print end if next iend subfunction isws(m) as boolean dim s% s = 0 for i = 1 to m 2 if m mod i = 0 then redim preserve a(j) a(j) = i j = j + 1 s = s + i end if next i if m = s then isws = trueend functionf7private sub delestr(s1 as string, byval s2 as string) dim i% ls2 = len(s2) i = ins
38、tr(s1, s2) do while i 0 s1 = left(s1, i - 1) + mid(s1, i + ls2) 在s1中去除s2子串 i = instr(s1, s2) loopend subprivate sub command1_click() 調(diào)用delestr子過程 dim ss1 as string ss1 = text1 call delestr(ss1, text2) text3 = ss1end subprivate sub command2_click()end subf8private sub command1_click()dim maxw$maxlen
39、text1 & , maxwtext2 = maxwend subsub maxlen(s$, maxw$) dim word$ maxw = do while s i = instr(s, ) word = left(s, i - 1) if len(word) len(maxw) then maxw = word s = mid(s, i + 1) loopend sub實驗gg1private sub command1_click() list1.clear list1.additem combo1 if option1 then list1.additem pentium ii if option2 then list1.additem pent
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 授權(quán)經(jīng)營合同范本
- 房屋建筑工程協(xié)議2024年
- 標(biāo)準(zhǔn)傷殘賠償協(xié)議書參考
- 2023年高考地理第一次模擬考試卷-(廣東B卷)(考試版)A4
- 【人教版系列】四年級數(shù)學(xué)下冊全冊專項測評(含答案)
- 關(guān)于離婚協(xié)議書的撰寫指南
- 山地資源保護(hù)承包協(xié)議書
- 2024版農(nóng)業(yè)機(jī)械租賃合同
- 合同違約訴訟程序指導(dǎo)
- 微店供應(yīng)商入駐服務(wù)協(xié)議2024年
- 遼寧省大連市金普新區(qū)2024-2025學(xué)年七年級上學(xué)期11月期中英語試題(無答案)
- 生態(tài)文明學(xué)習(xí)通超星期末考試答案章節(jié)答案2024年
- 區(qū)病案質(zhì)控中心匯報
- 期中測試卷(1-4單元)(試題)2024-2025學(xué)年四年級上冊數(shù)學(xué)人教版
- 教育局職業(yè)院校教師培訓(xùn)實施方案
- 《萬維網(wǎng)服務(wù)大揭秘》課件 2024-2025學(xué)年人教版新教材初中信息技術(shù)七年級全一冊
- 2024年新華社招聘應(yīng)屆畢業(yè)生及留學(xué)回國人員129人歷年高頻難、易錯點(diǎn)500題模擬試題附帶答案詳解
- 人教版(2024新版)七年級上冊英語Unit 5單元測試卷(含答案)
- 美食行業(yè)外賣平臺配送效率提升方案
- 中國民用航空局信息中心招聘筆試題庫2024
- 芯片設(shè)計基礎(chǔ)知識題庫100道及答案(完整版)
評論
0/150
提交評論