VB程序设计作业参考答案

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

《VB程序设计》作业参考答案

一.选择题

1-5 ABC CB 6—10 CCA DC 11-15 ABC DB 15-20CDA CB 21-25DBD CC

25-30DAC AA 31-35 DAC AA 36-40 BCC CD 41-45 CCC AC 46-50DDB AD 51-55 ACA CD 56-60 BCA DA 61-65 BAADB 66-70DBDAC 71-75BBBAD 76—80CDABC 81-85ABCD C 86-90BAADD 91-95CBBAD 96.B

二.填空题

(1) E (2) 程序代码(3) CmdDisplay.Visible =False(4) t=a(j)(5) And

(6) 回车符(7) text2.setfocus (8) 3 (9) D=B:B=C:C=D (10) Random

(11)事件过程(12) 打开对话框(13) 3 (14) a(i,j)=0 (15) L1.text

(16) Put # (17) True (18) I MOD 4=0 (19) AaBbCc (20)INT(Rnd*100) ;arr (21)Output ;Write #1,StuNo,StuName,StuEng (22)10 (23)4 (24) 顺序,随机

(25)INPUT,OUTPUT,APPEND (26)程序代码窗口的字符过大或过小,可以通过(工具→选项→编辑器格式→大小)去改变。(27)窗体、控件、对象(28)界面设计(29)对象、代码(30)窗体、标准模块、类模块、工程(31)窗体(Form)、图片框(PictureBox)、打印机(Printer)、立即窗口(Debug) (32)E D(33)81 (34)程序,数据(35)窗体、控件、对象(36)对象、代码(37)用户界面的窗体、执行具体操作的代码。(38)Picture属性、剪切板把图形粘贴

三.编程题

1.

Option Base 1

Private Sub Form_click()

Dim a(3) As Integer, m As Integer

Do While m <> -1 And i < 3

m = InputBox("请输入第" & i + 1 & "条边")

i = i + 1

a(i) = m

If a(i) < 0 Then

MsgBox "输入错误,请重新输入!"

i = i - 1

End If

Loop

If a(1) + a(2) > a(3) And Abs(a(1) - a(2)) < a(3) Then

s = (a(1) + a(2) + a(3)) / 2

s = Sqr(s * (s - a(1)) * (s - a(2)) * (s - a(3)))

Print "三角形的面积是"; s

Else

MsgBox "三条边不能构成三角形!"

End

End If

End Sub

2.

Option Base 1

Private Sub Form_click()

Dim a, b

a = Array(2, 8, 7, 6, 4, 28, 70, 25)

b = Array(79, 27, 32, 41, 57, 66, 78, 80)

Dim c(8)

For i = 1 To 8

c(i) = a(i) + b(i)

Print c(i);

Next i

End Sub

3.

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

Print spc(3); Chr$(KeyCode); spc(3); Hex$(KeyCode); spc(3); Oct$(KeyCode); spc(3); KeyCode End Sub

Private Sub Form_Load()

Print

Show

Print spc(3); "按键"; spc(3); "16进制"; spc(3); "8进制"; spc(3); "10进制" Print

End Sub

4.

Dim a(3) As Long, s As Long, p As Long '通用-声明

Sub Su(n As Long) '通用sub

p = 1

For i = 1 To n

p = p * i

Next i

End Sub

Function F(n As Long) As Long '通用Function

p = 1

For i = 1 To n

p = p * i

Next i

F = p

End Function

Private Sub Command1_Click()

s = 0

For i = 1 To 3

a(i) = InputBox("请输入第" & i & " 个数的值:")

Call Su(a(i))

s = s + p

Next i

Print "用Sub过程求得"; a(1); "! +"; a(2); "! +"; a(3); "! ="; s

End Sub

Private Sub Command2_Click()

s = 0

For i = 1 To 3

a(i) = InputBox("请输入第" & i & " 个数的值:")

s = s + F(a(i))

Next i

Print "用Function过程求得"; a(1); "! +"; a(2); "! +"; a(3); "! ="; s

End Sub

Private Sub Command3_Click()

相关文档
最新文档