VisualBasic程序設(shè)計課后題答案_第1頁
VisualBasic程序設(shè)計課后題答案_第2頁
VisualBasic程序設(shè)計課后題答案_第3頁
VisualBasic程序設(shè)計課后題答案_第4頁
VisualBasic程序設(shè)計課后題答案_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、Vb課后題答案參考答案第1章 概述第3章 常用標(biāo)準(zhǔn)控件二選擇題:1.C 2. B 3.C. 4.D 5.B 6.B 7.A 8.C 9.B 10.C11.C 12.A 13.C 14.B 15.D16.D 17.C 18.A 19.D 20.A 21.B三編程及上機調(diào)試:1.Private Sub Check1_Click()If Check1.Value = 1 ThenText1.FontBold = TrueElseText1.FontBold = FalseEnd IfEnd SubPrivate Sub Check2_Click()If Check2.Value = 1 ThenTe

2、xt1.FontItalic = TrueElseText1.FontItalic = FalseEnd IfEnd SubPrivate Sub Check3_Click()If Check1.Value = 1 ThenText1.FontUnderline = TrueElseText1.FontUnderline = FalseEnd IfEnd SubPrivate Sub Command1_Click()Text1.Text = End Sub2. Private Sub Command1_Click()Text2.Text = List1.ListCountEnd SubPriv

3、ate Sub Command2_Click()List1.AddItem Text1.TextText1.Text = End SubPrivate Sub Command3_Click()Dim i As Integeri = List1.ListIndexList1.RemoveItem iCommand3.Enabled = FalseText1.SetFocusText2.Text = List1.ListCountEnd SubPrivate Sub Form_Load()Command3.Enabled = FalseEnd SubPrivate Sub List1_Click(

4、)Command3.Enabled = TrueEnd Sub第4章 VB語言基礎(chǔ)二選擇題:1.A 2. D 3.D. 4.A 5.A 6.A 7.C 8.D 9.C 10.B11.A 12.D 13.C 14.A 15.A16.C 17.D 18.A 19.B 20.D 21.C 22.A 23.B 24.C 25.C三編程及上機調(diào)試:1Private Sub Form_Load() Dim x As Integer, s As String, d As Integer Randomize x = Int(Rnd * 9000 + 1000) s = Trim(CStr(x) d = Val

5、(Right(s, 1) + Mid(s, 3, 1) + Mid(s, 2, 1) + Left(s, 1) Show Print 產(chǎn)生的數(shù);; x; 倒序數(shù); dEnd Sub2Private Sub Form_KeyPress(KeyAscii As Integer) Print 輸入字符:; Chr(KeyAscii), ASCII碼為:; KeyAsciiEnd SubPrivate Sub Form_DblClick() ClsEnd Sub3Private Sub Form_Click() MsgBox 在這里顯示提示 & vbCrLf & 提示信息, 2 + 16, 請確認(rèn)En

6、d Sub或Private Sub Form_Click()MsgBox 在這里顯示提示 + Chr(13) + 提示信息, vbAbortRetryIgnore _+ vbCritical, 請確認(rèn)End Sub第5章 程序控制結(jié)構(gòu)二單選題1.D 2. C 3.C. 4.D. 5.B 6.C 7.A 8.A 9.D 10.C11.C 12.C 13.B 14.B 四編程及上機調(diào)試1. Private Sub Form_Click() Dim x As Integer, y As Integer x = InputBox(請輸入一個數(shù)值) If x 20 Then y = x 2 + 3 *

7、x + 2 ElseIf x = 10 Then y = Sqr(3 * x) - 2 ElseIf x 0 Then y = 1 / x + Abs(x) End If Print x=; x, y=; yEnd Sub(2)Select Case實現(xiàn):Private Sub Form_Click() Dim x As Integer, y As Integer x = InputBox(請輸入一個數(shù)值) Select Case x Case Is 20 y = x 2 + 3 * x + 2 Case 10 To 20 y = Sqr(3 * x) - 2 Case Is 0 y = 1

8、/ x + Abs(x) End SelectPrint x=; x, y=; yEnd Sub2.Private Sub Form_Click()Dim a As Integer, b As Integer, c As Integer For i = 100 To 999 a = i 100 b = (i - a * 100) 10 c = i Mod 10 If a 3 + b 3 + c 3 = i Then Print i; k = k + 1 If k Mod 2 = 0 Then Print End If Next iEnd Sub3Private Sub Command1_Cli

9、ck() p = 60: r = 0.014 Do p = p * (1 + r) n = n + 1 Loop Until p = 70 Print n; 年后世界人口達(dá)到; p; 億End Sub4Private Sub Command1_Click() Dim s As Single, x As Integer, t As Single, n As Integer x = Val(InputBox(請輸入x的值, , 2) s = 1 n = 1 m = 1 Do n = n + 1 m = -m t = m * n / x (n - 1) If Abs(t) Max Then Max

10、= a(i, j) k = i p = j End If Next jNext iPrint 最大的數(shù)為第 & k & 行,第 & p & 列的數(shù): & MaxEnd Sub3.Option Base 1Dim a(4, 5) As Integer 在窗體聲明段聲明數(shù)組Dim i As Integer, j As IntegerPrivate Sub cmdmatrix_Click() 生成數(shù)組按鈕 Randomize For i = 1 To 4 For j = 1 To 5 a(i, j) = Int(Rnd * 10) 一位的隨機數(shù) Picture1.Print a(i, j); 輸出元

11、素 Next j Picture1.Print Next iEnd SubPrivate Sub cmdcol_Click() 求列和按鈕 Dim colsum As Integer txtcol.Text = For j = 1 To 5 列變量先循環(huán) colsum = 0 For i = 1 To 4 colsum = colsum + a(i, j) Next i txtcol.Text = txtcol.Text & Str(colsum) Next jEnd SubPrivate Sub cmdrow_Click() 求行和按鈕 Dim rowsum As Integer txtro

12、w.Text = For i = 1 To 4 行變量先循環(huán) rowsum = 0 For j = 1 To 5 rowsum = rowsum + a(i, j) Next j txtrow.Text = txtrow.Text & CStr(rowsum) & vbCrLf Next iEnd SubPrivate Sub cmdclear_Click() 清除按鈕 Picture1.Cls txtcol.Text = txtrow.Text = End SubPrivate Sub cmdexit_Click() 結(jié)束按鈕 EndEnd Sub4. Option Base 1Privat

13、e Sub Form_Click() Dim a() As Integer, b() As Integer, i As Integer, j As Integer, x As Integer, y As Integer x = InputBox(第一維上界) Do While Not IsNumeric(x) x = Int(InputBox(第一維上界) Loop y = InputBox(第二維上界) Do While Not IsNumeric(x) y = Int(InputBox(第二維上界) Loop ReDim a(x, y) Print 原數(shù)組元素為: For i = 1 To

14、 x For j = 1 To y a(i, j) = Int(90 * Rnd) + 10 Print a(i, j); Next j Print Next i Print 轉(zhuǎn)置后數(shù)組元素為: For i = 1 To y For j = 1 To x Print a(j, i); Next j Print Next iEnd Sub5. Option Base 1Private Sub Form_Click()Dim a(10, 10) As Integer, i As Integer, j As IntegerFor i = 1 To 10 For j = 1 To 10 If i =

15、j Or i + j = 11 Then a(i, j) = 0 Else a(i, j) = 1 End If Print a(i, j); Next j PrintNext iEnd Sub6. Option ExplicitOption Base 1Private Sub Command1_Click() Dim i As Integer, j As Integer, n As Integer, k As Integer, a(11) As Integer j = 1 For i = 3 To 21 Step 2 a(j) = i Print a(j); j = j + 1 Next i

16、 Print n = InputBox(請輸入一個數(shù)) For i = 1 To 10 If n = a(i) Then For j = i To 10 a(j) = a(j + 1) k = k + 1 Next j End If Next i For i = 1 To 9 Print a(i); Next iEnd Sub7. Option Base 1Private Sub Form_Click()Dim a As Variant, k As Integer, i As Integer, j As IntegerDim b As Variantb = Array(17, 35, 128, 235, 89, 121, 143, 189, 231, 94)a = Array(11.3, 12.3, 12#, 11.8, 12.6, 11.6, 12.8, 11.8, 12.4, 12.1)For i = 1 To 9 對數(shù)組a的元素排序 k = i For j = i + 1 To 10 If a(k) a(j)

溫馨提示

  • 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論