好文档 - 专业文书写作范文服务资料分享网站

VB程序设计教程(第3版)课后实验答案

天下 分享 时间: 加入收藏 我要投稿 点赞

End If Next k Next j Next i End Sub

Private Sub Command3_Click() formd6.Hide main.Show End Sub

D.7

Private 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) < 0.00001 Then Exit Do x0 = x1 Loop Print x1, i End Sub

D.8

Private Sub Command1_Click() s = 0 x0 = 0.01

For i = 1 To 30 s = s + x0 x0 = x0 * 2 Next i Print s End Sub

D.9

Private Sub Command4_Click() Picture1.Cls

Picture1.Print \课安排在 \课安排在Picture1.Print \For z = 5 To 6 For x = 1 To z - 2 For Y = x + 1 To z - 1

\课安排在 \

X1 = Choose(Weekday(x), \周一\周二\周三\周四\周五\周六\周日\Y1 = Choose(Weekday(Y), \周一\周二\周三\周四\周五\周六\周日\z1 = Choose(Weekday(z), \周一\周二\周三\周四\周五\周六\周日\Picture1.Print \ \ \Next Y Next x Next z End Sub

E.1

Private Sub Form_Click() Dim a(1 To 10) As Integer For i = 1 To 10

a(i) = Int(Rnd * 71 + 30) Print a(i); \ Next i

Max = a(1) Min = a(1) Avg = a(1) For i = 2 To 10

If a(i) > Max Then Max = a(i) If a(i) < Min Then Min = a(i) Avg = Avg + a(i) Next i

Avg = Avg / 10 Print

Print \ Min=\End Sub

E.2

Private Sub Form_Click() Dim a

a = Array(56, 78, 98, 88, 76, 78) For i = 0 To 5

Print String(a(i) \\ 5, \◆\ Print Next i End Sub

E.3

Dim a%(19)

Private Sub Command1_Click() Picture1.Cls

Avg=\

For i = 0 To 19

a(i) = Int(Rnd * 101) Picture1.Print a(i); \ \

If (i + 1) Mod 4 = 0 Then Picture1.Print Next i End Sub

Private Sub Command2_Click() Picture2.Cls Dim 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 '90~100分的人数 s(9) = s(9) + 1

Case 6 To 8 ' 存放其他三个分数段的下标有规律,根据K获得 s(k) = s(k) + 1 End Select Next i

For i = 5 To 9

If s(i) <> 0 Then Picture2.Print \的人数有 \个\ Next i End Sub

E.4

Private Sub Command1_Click() Picture1.Cls

Dim d%(1 To 10) For i3 = 1 To 10 Randomize

d(i3) = Int(Rnd * 91 + 10) Next i3

For i = 1 To 10 For j = 1 To 10 - i If d(j) < d(j + 1) Then

t = d(j): d(j) = d(j + 1): d(j + 1) = t End If Next j Next i

For i = 1 To 10: Picture1.Print d(i); If i Mod 5 = 0 Then Picture1.Print Next i

End Sub

E.5

Dim a%(3, 3), b%(3, 3) Private Sub Form_Load() For i = 0 To 3 For j = 0 To 3

a(i, j) = Int(Rnd * 36 + 35) b(i, j) = Int(Rnd * 41 + 100) Next j Next i End Sub

Private Sub Command1_Click() Picture1.Cls For i = 0 To 3 For j = 0 To i

Picture1.Print a(i, j); \ \ Next j

Picture1.Print Next i End Sub

Private Sub Command2_Click() Picture2.Cls For i = 0 To 3 For j = i To 3

Picture2.Print Tab(j * 6); b(i, j); Next j

Picture2.Print Next i End Sub

Private Sub Command3_Click() Picture3.Cls sa = 0

For i = 0 To 3 sa = sa + a(i, i) Next i sb = 0

For i = 0 To 3

sb = sb + b(i, 3 - i) Next i

Picture3.Print \数组主对角线元素和为:\ Picture3.Print \数组副对角线元素和为:\End Sub

E.6

Private Sub Form_Click() n = InputBox(\输入n值\ReDim a6%(n + 1, n + 1)

a6(0, 0) = 1: a6(1, 1) = 1: a6(1, 0) = 1 For i = 2 To n + 1 For j = 2 To i

a6(i, j) = a6(i - 1, j - 1) + a6(i - 1, j) Picture1.Print a6(i, j); \ Next j

Picture1.Print Next End Sub

E.7

Private Sub Form_Load() List1.Clear

List1.AddItem \大学计算机基础\ List1.AddItem \程序设计\ List1.AddItem \程序设计\ List1.AddItem \程序设计\ List1.AddItem \多媒体技术与应用\ List1.AddItem \数据库技术与应用\ List1.AddItem \网络技术与应用\ List1.AddItem \硬件技术基础\ List1.AddItem \软件技术技术基础\End Sub

Private Sub List1_Click()

If List2.ListCount >= 5 Then

MsgBox (\超过5门课程,不能再选\ Exit Sub Else

List2.AddItem List1.Text

List1.RemoveItem List1.ListIndex End If End Sub

E.8

Sub Combo1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 48 To 57, 13 Case Else

VB程序设计教程(第3版)课后实验答案

EndIfNextkNextjNextiEndSubPrivateSubCommand3_Click()formd6.Hidemain.ShowEndSubD.7PrivateSubCommand1_Click()Dima!,x0!,x1!a=27x0=2i=0
推荐度:
点击下载文档文档为doc格式
8q0098uzgc4ddq243gyf
领取福利

微信扫码领取福利

微信扫码分享