VB程序的設(shè)計(jì)教程實(shí)驗(yàn)指導(dǎo)與習(xí)題解答上機(jī)答案_第1頁(yè)
VB程序的設(shè)計(jì)教程實(shí)驗(yàn)指導(dǎo)與習(xí)題解答上機(jī)答案_第2頁(yè)
VB程序的設(shè)計(jì)教程實(shí)驗(yàn)指導(dǎo)與習(xí)題解答上機(jī)答案_第3頁(yè)
VB程序的設(shè)計(jì)教程實(shí)驗(yàn)指導(dǎo)與習(xí)題解答上機(jī)答案_第4頁(yè)
VB程序的設(shè)計(jì)教程實(shí)驗(yàn)指導(dǎo)與習(xí)題解答上機(jī)答案_第5頁(yè)
已閱讀5頁(yè),還剩66頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、 WORD 自測(cè)1程序代碼Private Sub Command1_Click()Label1.FontSize = Label1.FontSize + 3End SubPrivate Sub Command2_Click()Label1.FontBold = TrueEnd SubPrivate Sub Command3_Click()Label1.FontUnderline = TrueEnd SubPrivate Sub Command4_Click()Label1.FontSize = 10Label1.FontBold = FalseLabel1.FontUnderline = Fa

2、lseEnd Sub初始窗口:?jiǎn)螜C(jī)放大之后窗口:?jiǎn)螜C(jī)下劃線之后窗口:?jiǎn)螕艏哟种蟠翱冢簡(jiǎn)螕暨€原之后窗口:自測(cè)2程序代碼Private Sub Command1_Click()Label1 = visual basicText1 = 程序設(shè)計(jì)題End SubPrivate Sub Command2_Click()Text1 = visual basicLabel1 = 程序設(shè)計(jì)題End Sub初始窗口:?jiǎn)螕麸@示之后窗口:?jiǎn)螕艚粨Q之后的窗口:自測(cè)題3Private Sub Command1_Click()Label1.FontSize = Label1.FontSize * (0.5)End Su

3、bPrivate Sub Command2_Click()Label1.Top = Label1.Top + 30Label1.Width = Label1.Width + 20Label1.Alignment = 1End Sub初始窗口:?jiǎn)螕艨s小兩倍之后的窗口:?jiǎn)螕粝蛴蚁陆且苿?dòng)之后的窗口:自測(cè)題4程序代碼Private Sub Command1_Click()Form1.Caption = VB學(xué)習(xí)Print 簡(jiǎn)單的VB程序設(shè)計(jì)End SubPrivate Sub Command2_Click()ClsEnd SubPrivate Sub Command3_Click()EndEnd Su

4、bPrivate Sub Command3_Click()EndEnd Sub初始化窗口:?jiǎn)螕麸@示之后的窗口:?jiǎn)螕羟宄蟮拇翱冢簡(jiǎn)螕敉顺鲋蟮拇翱冢鹤詼y(cè)題5程序代碼Private Sub Command1_Click()Text1.Text = Text2.Text = End SubPrivate Sub Command2_Click()Text3.Text = Val(Text1.Text) + Val(Text2.Text)End SubPrivate Sub Command3_Click()EndEnd Sub初始化窗口:?jiǎn)螕暨\(yùn)算之后窗口:?jiǎn)螕羟宄蟮拇翱冢簡(jiǎn)螕敉顺鲋蟮拇翱冢鹤詼y(cè)

5、練習(xí)1Private Sub Command1_Click()Dim a$a = Text1.TextLabel1.Caption = Left(a, 2)End SubPrivate Sub Command2_Click()a = Text1.TextLabel2.Caption = Right(a, 2)End SubPrivate Sub Command3_Click()Text1.Text = Label1.Caption & Label2.CaptionEnd Sub初始窗口界面輸入字符串截取前兩個(gè)字符截取后兩個(gè)字符字符串連接自測(cè)練習(xí)2Private Sub Form_Click()

6、Dim a%, b%, c%, d%, e%, f%, g%, h%, i%, j%, k%, l%a = 7349e = a Mod 10 個(gè)位d = (a 10) Mod 10 十位c = (a 100) Mod 10 百位b = a 1000 千位i = (e + 7) Mod 10 個(gè)位h = (d + 7) Mod 10 十位g = (c + 7) Mod 10 百位f = (b + 7) Mod 10 千位j = ii = f 交換后的個(gè)位f = j 交換后的千位k = hh = g 交換后的十位g = k 交換后的百位l = f * 1000 + g * 100 + h * 10

7、 + iText1.Visible = FalsePrint 加密前的4位整數(shù)是7439; (Chr(10); 加密后的結(jié)果是; lEnd Sub初始界面單擊窗體運(yùn)行后的界面自測(cè)練習(xí)1Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox(輸入第一個(gè)數(shù), 輸入一個(gè)數(shù), 8)b = Val(InputBox(輸入第一個(gè)數(shù), 輸入一個(gè)數(shù), 7)c = a + bd = a - be = a * bf = a / bf = Fix(f * 100 + 0.5) / 100MsgBox x+y= & c & Chr(10)

8、& x-y= & d & Chr(10) & x*y= & e & Chr(10) & x/y= & f, , 輸出的結(jié)果End Sub自測(cè)練習(xí)2Private Sub Form_Click()Dim a%, b%, c%, d%, e%, f!a = Val(InputBox(輸入第一個(gè)數(shù)的值)b = Val(InputBox(輸入第二個(gè)數(shù)的值)c = Val(InputBox(輸入第三個(gè)數(shù)的值)d = Val(InputBox(輸入第四個(gè)數(shù)的值)e = a + b + c + df = e / 4Print 和=; ePrint 平均值=; fEnd Sub自測(cè)練習(xí)3Private Sub

9、 Form_Click()Dim h%, f%, x%, y%h = Val(InputBox(輸入總頭數(shù))f = Val(InputBox(輸入總腳數(shù))x = (4 * h - f) / 2y = (f - 2 * h) / 2Print 籠中雞的頭數(shù)為; x; 只Print 籠中兔的頭數(shù)為; y; 只End Sub自測(cè)練習(xí)1:Private Sub Form_Click()Dim a%, b%, c%a = Val(InputBox(請(qǐng)輸入第一條邊, 邊長(zhǎng))b = Val(InputBox(請(qǐng)輸入第二條邊, 邊長(zhǎng))c = Val(InputBox(請(qǐng)輸入第三條邊, 邊長(zhǎng))If a + b

10、c And a + c b And b + c a ThenIf a * a + b * b = c * c Or a * a + c * c = b * b Or b * b = c * c = a * a ThenPrint 直角ElseIf a = b And b = c ThenPrint 等邊三角形ElseIf a = b Or a = c Or b = c ThenPrint 等腰三角形ElsePrint 一般三角形End IfElsePrint 不是三角形End IfEnd Sub不是三角形運(yùn)行結(jié)果:初始窗口:輸入三條邊:運(yùn)行結(jié)果:直角三角形運(yùn)行結(jié)果:等邊三角形運(yùn)行結(jié)果如下:等腰

11、三角形:一般三角形自測(cè)練習(xí)2:Private Sub Form_Click()Dim a%, b!a = Val(InputBox(請(qǐng)輸入)If a Mod 2 = 0 And a Mod 3 = 0 And a Mod 5 = 0 Thenb = Sqr(a)Print a, bElseEndEnd IfEnd Sub初始化窗口:輸入一個(gè)數(shù):運(yùn)行結(jié)果:自測(cè)練習(xí)3Private Sub Command1_Click()Dim a%, b%a = Val(Text1.Text)Select Case a 0Case a = 20 And a = 50 And a = 1c = Chr(a Mod

12、 10 + 48) & ca = a 10WendText2.Text = c End SubPrivate Sub Command1_Click()Dim a As Integera = Val(Text1.Text)Call itostr(a)End Sub運(yùn)行初始界面:運(yùn)行結(jié)果界面:驗(yàn)證其他數(shù)字:自測(cè)練習(xí)2:Public Function area(n) As DoubleDim c#, d#, e#, s#n = Val(Text2.Text)c = (1 - 0) / nWhile e a(j) Then t = a(i): a(i) = a(j): a(j) = t End If

13、Next jNext iFor i = 1 To 5Print a(i); ;Next iFor i = 1 To 5 If Y Combo1.ListCount - 1 ThenCombo1.AddItem Combo1.TextEnd IfEnd SubPrivate Sub Command2_Click()If Combo1.ListIndex -1 ThenCombo1.RemoveItem Combo1.ListIndexFor i = 0 To Combo1.ListCount - 1If Combo1.List(i) = Combo1.Text ThenCombo1.Remove

14、Item iEnd IfExit ForNext iEnd IfEnd SubPrivate Sub Command3_Click()Combo1.ClearEnd Sub運(yùn)行初始界面:自測(cè)練習(xí)7:Private Sub Command1_Click()Timer1.Interval = 1Timer1.Enabled = TrueEnd SubPrivate Sub Form_Load()lbltemp1.FontSize = 20lbltishi.FontSize = 20Label1.FontSize = 20Label2.FontSize = 20End SubPrivate Sub

15、Timer1_Timer()VSbwd.Value = VSbwd.Value + 10lbltem = VSbwd.ValueIf VSbwd = 100 Thenlbltishi = 水開(kāi)了Timer1.Enabled = FalseEnd IfEnd Sub運(yùn)行初始界面:運(yùn)行結(jié)果:自測(cè)練習(xí)1:Private Sub myhelp_Click()frmAbout.ShowEnd SubPrivate Sub mymenu1_Click()Text1.Text = 百貨大樓End SubPrivate Sub mymenu2_Click()Text1.Text = 利客隆End SubPri

16、vate Sub mymenu3_Click()Text1.Text = 稻香村End Sub運(yùn)行初始界面:運(yùn)行結(jié)果界面:自測(cè)練習(xí)2:Private Sub Dis_Click()Text1.Text = 菜單程序設(shè)計(jì)Text1.FontSize = 20Text1.FontName = 黑體End SubPrivate Sub Hid_Click()Text1.Visible = FalseEnd Sub運(yùn)行初始界面:運(yùn)行結(jié)果界面:自測(cè)練習(xí)3:Private Sub vbhelp_Click()r = MsgBox(幫助, , 程序設(shè)計(jì)題)End SubPrivate Sub Vbnew_C

17、lick()r = MsgBox(新建, , 程序設(shè)計(jì)題)End SubPrivate Sub vbopen_Click()r = MsgBox(打開(kāi), , 程序設(shè)計(jì)題)End SubPrivate Sub vbsave_Click()r = MsgBox(存盤(pán), , 程序設(shè)計(jì)題)End Sub運(yùn)行初始界面:運(yùn)行結(jié)果:自測(cè)練習(xí)4:Private Sub Command1_Click()CommonDialog1.Action = 1List1.AddItem CommonDialog1.FileNameEnd Sub運(yùn)行初始界面:運(yùn)行結(jié)果:自測(cè)練習(xí)1:Private Sub Command1_

18、Click()Dim a As String, n%, i%, j%Open E:Data.txt For Input As #1Input #1, an = Len(a)j = 0For i = 1 To nIf Mid(a, i, 1) = % Then j = j + 1Next iClose #1Open E:Datares.txt For Output As #1Print #1, jClose #1End Sub運(yùn)行初始界面:運(yùn)行結(jié)果:自測(cè)練習(xí)3:Private Sub Form_Click()Dim x$Open e:txt2.txt For Input As #1Do While Not EOF(1)Line Input #1, x$LoopClose #1Open e:txt1.txt For Append As #1Print #1, x$Close #1End Sub運(yùn)行初始界面:自測(cè)練習(xí)4Private Sub Form_load()Print 26個(gè)英文字母PrintPrint a b c d e f g h i j k l m n o p q r s t u v w x y zPrint 字母?jìng)€(gè)數(shù)分別為End SubPrivate Sub F

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論