版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、A1Private Sub Command1_Click() Label3 = Text1End SubA2Private Sub Form_Load() Timer1.Interval = 0End SubPrivate Sub Command1_Click() 自動(dòng) Timer1.Interval = 200End SubPrivate Sub Command2_Click() 手動(dòng) Timer1.Interval = 0 Call MyMoveEnd SubPrivate Sub Timer1_Timer() Call MyMoveEnd SubSub MyMove() Label1.M
2、ove 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_Db
3、lClick() 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 + 200
4、 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 SubB1Private Sub Command1_Click() Text2 = Format(5 / 9 * (Val(Text1) - 32), 0.00)E
5、nd SubPrivate Sub Command2_Click() Text1 = Format(9 / 5 * Val(Text2) + 32, 0.00)End Sub或Private Sub Command1_Click() Dim f!, c! 聲明兩個(gè)變量 f = Val(Text1) c = 5 / 9 * (f - 32) Text2 = Format(c, 0.00) 保留兩位小數(shù)End SubPrivate Sub Command2_Click() Dim ff!, cc! 聲明兩個(gè)變量 cc = Val(Text2) ff = 9 / 5 * cc + 32 Text1
6、= 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ù)字字符,請(qǐng)重新輸入, , 警告 Text1
7、.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(Text1.T
8、ext) 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 字符串長(zhǎng)度為:; cdEnd SubB5Private Sub Command1_Click() Text1
9、= Int(Rnd * 900 + 100)End SubPrivate Sub Command2_Click() Dim x%, x1%, x2%, x3% x = Val(Text1) x1 = x Mod 10 分離出的個(gè)位數(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 = Right(Tex
10、t1, 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 - 1,
11、); String(10 - (2 * i - 1), ); String(2 * i - 1, ) Next iEnd SubPrivate Sub Command2_Click() ClsEnd SubB8Private Sub Form_Click()x = Val(InputBox(輸入一正實(shí)數(shù), 計(jì)算, 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 SubC1Private 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)時(shí)間)If x 10 Theny
13、 = 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 Print 排序
14、后 & 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 IfNext iPi
15、cture2.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(de) / t,
16、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) Case + Te
17、xt4 = 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(Text1) Case
18、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, Thursday, Friday
19、, Saturday, Sunday)End IfEnd SubD1Private 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&s = 1t = 1F
20、or i = 1 To 100000t = t + is = s + 1 / tIf 1 / t 0.00001 Then Exit ForNext iPrint For結(jié)構(gòu); s, i; 項(xiàng)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 & 時(shí),pi=; piEnd SubD5Private Sub Form_C
21、lick() 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 * 100 + j * 10
22、 + 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) Min Then M
23、in = 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 = 0 To 19 a(
24、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 存放其他三個(gè)分?jǐn)?shù)段的下標(biāo)有規(guī)律,根據(jù)K獲得 s(k) =
25、 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); 個(gè) 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 MsgBox (超過5門課程,
26、不能再選) 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 SubPrivate Sub Comma
27、nd1_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) Combo1.List(
28、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ù)組聲明的個(gè)數(shù))Else With a
29、(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 t = a(i): a(
30、i) = a(j + 1): a(j + 1) = t End If Next jNext iPicture1.ClsPicture1.Print 工號(hào) 姓名 工資For i = 0 To n - 1 Picture1.Print a(i).number, a(i).name, a(i).salary PrintNext iEnd SubF1Private 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 Call s(a(), am
31、in) 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 SubFunction gcd%(By
32、Val 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 Double Dim i%,
33、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(輸入要計(jì)算正弦函數(shù)的角度值x)x = x * 3.14 / 180End SubF4Private Sub Text1_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Not IsNume
34、ric(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, i, 1) Mid(ss,
35、 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 注意冒號(hào)和exit的范圍Next iEnd FunctionPrivate Sub Command1_Click()n = 0For i = 6 To 100 Step 2For j =
36、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; 對(duì)素?cái)?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(j); Next j Pri
37、nt 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 = InStr(s1, s2) Do W
38、hile 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 Text1 & , maxwT
39、ext2 = 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 SubG1Private Sub Command1_Click() List1.Clear List1.AddItem Combo1 If Option1 Then List1.AddItem Pentium II If Option2 Then List1.AddItem Pentium I If Option3 Then L
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 蘭州外語職業(yè)學(xué)院《五官醫(yī)學(xué)》2023-2024學(xué)年第一學(xué)期期末試卷
- 江西科技職業(yè)學(xué)院《中國(guó)民間美術(shù)》2023-2024學(xué)年第一學(xué)期期末試卷
- 濟(jì)南大學(xué)《現(xiàn)代控制理論及其仿真》2023-2024學(xué)年第一學(xué)期期末試卷
- 湖南信息職業(yè)技術(shù)學(xué)院《人體形態(tài)學(xué)》2023-2024學(xué)年第一學(xué)期期末試卷
- 湖南工程職業(yè)技術(shù)學(xué)院《體育舞蹈摩登》2023-2024學(xué)年第一學(xué)期期末試卷
- 衡水健康科技職業(yè)學(xué)院《生物工程實(shí)訓(xùn)理論與實(shí)踐》2023-2024學(xué)年第一學(xué)期期末試卷
- 重慶智能工程職業(yè)學(xué)院《手繪空間快速表現(xiàn)》2023-2024學(xué)年第一學(xué)期期末試卷
- 重慶健康職業(yè)學(xué)院《信號(hào)與系統(tǒng)理論教學(xué)》2023-2024學(xué)年第一學(xué)期期末試卷
- 中原科技學(xué)院《熱儲(chǔ)工程課程設(shè)計(jì)》2023-2024學(xué)年第一學(xué)期期末試卷
- 浙江汽車職業(yè)技術(shù)學(xué)院《土建工程基礎(chǔ)》2023-2024學(xué)年第一學(xué)期期末試卷
- 2024-2025學(xué)年八年級(jí)上學(xué)期1月期末物理試題(含答案)
- 2025年國(guó)新國(guó)際投資有限公司招聘筆試參考題庫含答案解析
- 制造車間用洗地機(jī)安全操作規(guī)程
- 2025河南省建筑安全員-A證考試題庫及答案
- 油氣田智能優(yōu)化設(shè)計(jì)-洞察分析
- 陜西2020-2024年中考英語五年真題匯編學(xué)生版-專題09 閱讀七選五
- 磚混結(jié)構(gòu)基礎(chǔ)加固技術(shù)方案
- 助產(chǎn)專業(yè)的職業(yè)生涯規(guī)劃
- 新《國(guó)有企業(yè)管理人員處分條例》知識(shí)競(jìng)賽考試題庫500題(含答案)
- MOOC 有機(jī)化學(xué)(上)-北京師范大學(xué) 中國(guó)大學(xué)慕課答案
- 五年級(jí)上冊(cè)脫式計(jì)算100題及答案
評(píng)論
0/150
提交評(píng)論