帮我找找这本书的答案吧,谢谢啦…… 《vb程序设计》 高等教育出版社 郑国平 王杰华主编

帮我找找这本书的答案吧,谢谢啦…… 《vb程序设计》 高等教育出版社 郑国平 王杰华主编,第1张

第一章:

一:选择题

1-5 CCCCA 6-10 CBACA11 A

二:填空题

1: 视图工具箱

2: 对象事件驱动

3: 代码窗体设计器

4: 属性方法事件

5: 对象的特征

6: 一个对象可执行的动作

7: 属性窗口赋值语句

三:简答题

1:略

2:略

四:编程题

【属性窗口设置】

Caption 这是我的第一个练习

【代码窗口设置】

Private Sub Form_Click()

Print "我可以用Visual Basic语言编写程序了!"

End Sub

第二章:

一:选择题

1-5: BDDCA

6-10: CBADD

11-15: DDBDB

16-20: DBCDC

21-23: CCD

二:填空题

1: Value

2: 下拉列表框

3: Scroll

4: LargeChange

5: ASCII码

6: Enabled

7: ListCount

8: PopupMenu

9: Alt

10:复选

11:CommonDialog1.ShowColor 或者: ShowColor

12:Flags

13: 1

14:-

15:GFED

第三章

一:选择题

1-5: ADADC

6-10: BCBDB

11-15:BBCBB

16-20:DCADA

21-25:ABCBB

26-30:DBBCB

31-34:BBDD

二:填空题

1: Right(CStr(x),1) &Left(CStr(x),1)

2: x Mod 5=0 Or x Mod 9=0

3: False

4: CDEF

5: s>="A" And s<="Z" Or s>="a" And s<="z"

6: x>=0 And x<100

7: Int(Rnd*(X-2)+3)

8: Sqr(cos(23*3.14/180)/(x^2*Log(y)))

9: -4 -5 -4

10:"请输入圆的半径:" "求圆的面积"2

11:"圆的半径值必须介于1到10之间,请重输" 48 "求圆的面积"

第四章

一:选择题

1-5: DCDAC

6-10: CCBDC

二:填空题

1: 4.8

20

2: y=11

3: 1!+2!+3!+4!+5!

4: 9

k

(学生我认为该题有错,应把其中的 n 改成 k)

5: 0

n

6: 2

7: x>=0

x>max

8: 57

13 12

14 11

9: sum=0

sum+j

st &k &"+"

10: 4

11

10

11: i + 1

List1.RemoveItem j

12: Combo1.List(i)=Combo1.Text

flag=false

Combo1.AddItem Combo1.Text

三:编程题

1:

Private Sub Form_Click()

Dim x As Single

x = Val(InputBox("请输入一个x的值:"))

If x <= 0 Then

fx = -1

ElseIf x <1 Then

fx = Sqr(x)

Else

fx = x ^ 3 + 2

End If

MsgBox ("运算结果为:" &fx)

End Sub

2:

Private Sub Form_Click()

Dim n As Integer, k As Integer, s As String

n = Val(InputBox("请输入一个正整数:"))

k = 2

s = n &"="

Do

If n Mod k = 0 Then

s = s &k &"*"

n = n \ k

Else

k = k + 1

End If

Loop Until n = k

s = s &k

Print s

End Sub

3:

Private Sub Form_Click()

Dim s As String, i As Integer

Dim a As Integer, b As Integer, c As Integer, d As Integer, e As Integer

s = Text1.Text

For i = 1 To Len(s)

If Mid(s, i, 1) >= "0" And Mid(s, i, 1) <= "9" Then

If Val(Mid(s, i, 1)) Mod 2 <>0 Then

a = a + 1

Else

b = b + 1

End If

ElseIf Mid(s, i, 1) >= "A" And Mid(s, i, 1) <= "Z" Then

c = c + 1

ElseIf Mid(s, i, 1) >= "a" And Mid(s, i, 1) <= "z" Then

d = d + 1

Else

e = e + 1

End If

Next i

Print "奇数个数为:"a

Print "偶数个数为:"b

Print "大写字母个数为:"c

Print "小写字母个数为:"d

Print "其他字符个数为:"e

End Sub

4:

Private Sub Form_Click()

Dim n As Integer, sum As Integer

n = Val(InputBox("请输入一个正整数:"))

Do Until n = 0

sum = sum + n Mod 10

n = n \ 10

Loop

MsgBox ("各位数字之和为:" &sum)

End Sub

5:

Private Sub Form_Click()

Dim n As Long, i As Integer, L As Integer

n = Val(InputBox("请输入一个正整数:"))

L = Len(CStr(n))

For i = 1 To L / 2

If Mid(CStr(n), i, 1) <>Mid(CStr(n), L, 1) Then

Exit For

End If

L = L - 1

Next i

If i >L / 2 Then

MsgBox ("该数是回文数。")

Else

MsgBox ("该数不是回文数。")

End If

End Sub

6:

Private Sub Command1_Click()

Dim a As Integer, b As Integer, c As Integer

For a = 1 To 30

For b = 1 To 30

For c = 1 To 30

If a ^ 2 + b ^ 2 = c ^ 2 And a <b Then

Print a, b, c

End If

Next c

Next b

Next a

End Sub

第五章

一:单选题

1-5: BCBBD

6-8: DAB

二:编程题

1:

Option Base 1

Private Sub Command1_Click()

Dim a(15) As Integer, i As Integer, j As Integer

Do

j = Int(Rnd * 90) + 10

If j Mod 2 <>0 Then

i = i + 1

a(i) = j

Label1.Caption = Label1.Caption &Str(a(i))

End If

Loop Until i = 15

For i = 1 To 14

For j = i + 1 To 15

If a(i) <a(j) Then

t = a(i)

a(i) = a(j)

a(j) = t

End If

Next j

Label2.Caption = Label2.Caption &Str(a(i))

Next i

Label2.Caption = Label2.Caption &Str(a(i))

End Sub

2:

Option Base 1

Private Sub Form_Click()

Dim a(10) As Integer, i As Integer, Max As Integer, Min As Integer, sum As Integer

For i = 1 To 10

a(i) = Int(Rnd * 90) + 10

Print a(i)

sum = sum + a(i)

Next i

Print

Max = a(1)

Min = a(1)

For i = 2 To 10

If a(i) >Max Then

Max = a(i)

ElseIf a(i) <Min Then

Min = a(i)

End If

Next i

Print "最大数为:"Max

Print "最小数为:"Min

Print "平均值为:"sum / 10

End Sub

3:

Private Sub Form_Click()

Dim a(0 To 25) As Integer, idx As Integer, i As Integer, S As String, ch As String * 1

S = InputBox("请输入一个字符串:")

Print "输入的字符串为:"S

For i = 1 To Len(S)

ch = Mid(S, i, 1)

If ch >= "A" And ch <= "Z" Then

idx = Asc(ch) - Asc("A")

a(idx) = a(idx) + 1

ElseIf ch >= "a" And ch <= "z" Then

idx = Asc(ch) - Asc("a")

a(idx) = a(idx) + 1

End If

Next i

Print "统计结果如下:"

For i = 0 To 25

Print Chr(Asc("A") + i)":"a(i)"次"

Next i

End Sub

4:

Option Base 1

Private Sub Form_Click()

Dim a() As Integer, m As Integer, n As Integer

Dim i As Integer, j As Integer, Max As Integer

m = Val(InputBox("请输入行数:"))

n = Val(InputBox("请输入列数:"))

ReDim a(m, n)

For i = 1 To m

For j = 1 To n

a(i, j) = Int(Rnd * 90) + 10

Print a(i, j)

If a(i, j) >Max Then Max = a(i, j)

Next j

Print

Next i

Print

For i = 1 To m

For j = 1 To n

If a(i, j) = Max Then

Print "最大元素是:"a(i, j)

Print "行号:"i

Print "列号:"j

End if

Next j

Next i

End Sub

5:

Option Base 1

Private Sub Form_Click()

Dim a(5, 5) As Integer, i As Integer, j As Integer

Dim sum1 As Integer, sum2 As Integer, sum3 As Integer

Print "随机生成数组元素:"

For i = 1 To 5

For j = 1 To 5

a(i, j) = Int(Rnd * 9) + 1

Print a(i, j)

sum3 = sum3 + a(i, j)

If i = 1 Or i = 5 Or j = 1 Or j = 5 Then

sum2 = sum2 + a(i, j)

End If

Next j

Print

Next i

For i = 1 To 5

sum1 = sum1 + a(i, i) + a(i, 6 - i)

Next i

sum1 = sum1 - a(3, 3)

Print "对角线元素之和为:"sum1

Print "所有靠边元素之和为:"sum2

Print "所有数组元素之和为:"sum3

End Sub

6:

Option Base 1

Private Sub Form_Click()

Dim a() As Integer, b() As Integer, n As Integer, k As Integer, i As Integer, j As Integer

n = Val(InputBox("请输入n=", , 9)) + 1

ReDim a(n + 1, n + 1), b(n + 1, n + 1)

k = 8

For i = 1 To n

For j = 1 To i

a(i, 1) = 1

a(i, i) = 1

a(i + 1, j + 1) = a(i, j) + a(i, j + 1)

b(i, j) = a(i, j)

Print b(i, j)" "

Next j

Print

Next i

End Sub

第六章:

一:填空题

1:AFBECD

2:-5

5

3:2

4

6

8

4:33

5:5

无输出

6:1234

10

7:0

8:12 10

9:2

4

6

7

10:3 54 2 0 5 17 23

二:编程题

1:Private Sub Form_Click()

Dim s As String, n As Integer

s = InputBox("请输入待转数s=", "N进制转十进制")

n = Val(InputBox("请输入该数的进制n=", "N进制转十进制"))

Print Convert(s, n)

End Sub

Private Function Convert(ByVal s As String, ByVal n As Integer) As Integer

Dim i As Integer, j As Integer

For i = Len(s) To 1 Step -1

Convert = Convert + Mid(s, i, 1) * n ^ j

j = j + 1

Next i

End Function

2:要么由于资质太低,要么题意叙述不清。此题答案,仅供参考。

Private Sub Form_Click()

Dim y As Single, n As Integer, t As Single

t = 1 / 2

y = t

n = 1

Do Until t <= 1E-5

n = n + 1

t = t / (2 * n)

y = y + t

Loop

Print y

End Sub

3:

Option Base 1

Dim a() As Integer

Private Sub Command1_Click()

Dim n As Integer, i As Integer

n = Val(InputBox("请输入数据个数", "工程1", 10))

ReDim a(n)

For i = 1 To n

a(i) = Int(Rnd * 90) + 10

Text1 = Text1 &CStr(a(i)) &" "

Next i

End Sub

Private Sub Command2_Click()

Dim Max As Integer, Min As Integer, i As Integer, temp As Integer

Call Max_Min(Max, Min)

For i = 1 To UBound(a)

If a(i) = Max Then

temp = a(1)

a(1) = a(i)

a(i) = temp

Exit For

End If

Next i

For i = 1 To UBound(a)

If a(i) = Min Then

temp = a(UBound(a))

a(UBound(a)) = a(i)

a(i) = temp

Exit For

End If

Next i

For i = 1 To UBound(a)

Text2 = Text2 &CStr(a(i)) &" "

Next i

End Sub

Private Sub Max_Min(Max As Integer, Min As Integer)

Dim i As Integer

Max = a(1): Min = a(1)

For i = 2 To UBound(a)

If a(i) >Max Then

Max = a(i)

ElseIf a(i) <Min Then

Min = a(i)

End If

Next i

End Sub

Private Sub Command3_Click()

Text1.Text = ""

Text2.Text = ""

Command1.SetFocus

End Sub

4:

设计界面时:要将文本框的MultiLine属性设置成True

ScrollBars属性设置成 2

Private Sub Command1_Click()

Dim i As Integer

For i = 1000 To 9999

If Mid(i, 1, 1) = Mid(i, 4, 1) And prime(i) And prime(exchange(i)) And i <exchange(i) Then

Text1 = Text1 &"(" &i &" " &exchange(i) &")" &vbCrLf

End If

Next i

End Sub

Private Function prime(n As Integer) As Boolean

Dim k As Integer

For k = 2 To Sqr(n)

If n Mod k = 0 Then Exit Function

Next k

prime = True

End Function

Private Function exchange(n As Integer) As Integer

Dim t As String * 1, s As String

s = CStr(n)

t = Mid(s, 2, 1)

Mid(s, 2, 1) = Mid(s, 3, 1)

Mid(s, 3, 1) = t

exchange = s

End Function

Private Sub Command2_Click()

Text1.Text = ""

Command1.SetFocus

End Sub

Private Sub Command3_Click()

End

End Sub

有两本 都是针对江苏省的计算机二级

一本《新编 Visual Basic程序设计教程》苏州大学出版社 主编:牛又奇 孙建国 该书内容主要是笔试理论知识

一本《Visual Basic程序设计实验教程与习题选解》中国铁道出版社 主编:王杰华 郑国平 该书内容主要是上机实验 *** 作知识


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11001699.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-12
下一篇 2023-05-12

发表评论

登录后才能评论

评论列表(0条)

保存