1、郑州大学VB实验报告书 参考 答案郑州大学VB实验报告书 参考 答案 以下内容均来自XX文库,所以仅供参考。不过经亲自测试 习题及实验(一)的答案基本正确,除了实验题的3,4小题没有改字形字体颜色什么的。 实验一一、选择题DDBAB,C(CD)DDC,ADDCA二、填空题Windows中断工具箱代码分类form2.show有语法错误错误事件结构化文件名和结构工程编写代码双击任意控件或右健快捷菜单选“代码窗口”vb的安装文件夹属性方法fontload对象三、编程1-1Private Sub Command1_Click()Print Sqr(8), 8 (1 / 3)End Sub1-2Priv
2、ate Sub Command2_Click()For i = 100 To 110 Print Sqr(i)Next iEnd Sub1-3(基本设置在属性窗口完成!)Private Sub Command3_Click()Print 郑州大学在前进!End Sub1-4(基本设置在属性窗口完成!)Private Sub Command4_Click()Label1 = 蓝天、白云、绿水、青山End Sub实验二一BCBCC,CBBDA,CCCBA,CBDCC二form_click()interval,5000vbp,frmtop,left,height,width,像素pictureloa
3、dlockedfont,alignmentgotfocus,lostfocus属性窗口,代码三2-1Private Sub Command1_Click()Label3 = Text1 * Text2End SubPrivate Sub Command2_Click()Label3 = Text1 / Text2End Sub2-2Private Sub Command1_Click()Picture1.Visible = TruePicture1 = LoadPicture(C:Documentsand SettingsAll UsersDocumentsMy Pictures示例图片Wat
4、er lilies.jpg)End SubPrivate Sub Command2_Click()Picture1.Visible = TruePicture1 = LoadPicture(C:Documentsand SettingsAll UsersDocumentsMy Pictures示例图片Winter.jpg)End SubPrivate Sub Command3_Click()Picture1.Visible = FalseEnd Sub2-3Private Sub Command1_Click()Label3 = Text1 * Text2End Sub2-4Private S
5、ub Command1_Click()Text2 = Text1End SubPrivate Sub Command2_Click()Text1 = Text2 = End SubPrivate Sub Text1_Change()Command1.Visible = TrueCommand2.Visible = TrueEnd Sub2-5Private Sub Command1_Click()Timer1.Interval = 500End SubPrivate Sub Command2_Click()Timer1.Interval = 0End SubPrivate Sub Timer1
6、_Timer()Image1.Left = Int(Rnd * (Form1.ScaleWidth -Image1.Width)Image1.Top = Int(Rnd * (Form1.ScaleHeight -Image1.Height)End Sub实验三一A(BC)(BC)AA,A(BCD)DBB,B二3,4,5,6,8,10,11,12,14,15,16三abs(x+y)(3+x*y)2(-b+sqr(b2-4*a*c)/(2*a)sin(30*3.14/180)+exp(2)四int(rnd*71+20)x*y=10 and x=A and x=Zleft(s,3) 或者,mid(
7、s,1,3)五3-2Private Sub Command1_Click()Dim x As Singlex = Val(Text1)Print Format(x 2, #.000),Format(Sqr(x), #.000), Format(x 3, #.000), Format(x (1 / 3), #.000)End Sub3-3Private Sub Command1_Click()Dim x As Integerx = Int(Rnd * 900 + 100)Text1 = Trim(Str(x)Text2 = Right(Text1, 1) + Mid(Text1, 2, 1)+
8、Left(Text1, 1)End Sub3-4Private Sub Command1_Click()Dim max, min As Integermin = Val(Text1)max = Val(Text2)RandomizePrint Int(Rnd * (max - min + 1) + min),Int(Rnd * (max - min + 1) + min), Int(Rnd * (max - min + 1) + min)End Sub3-5Private Sub Command1_Click()Text1 = DateText2 = TimeText3 = WeekdayNa
9、me(Weekday(Date)End Sub实验四一CDCDA,DBBAC二(1) 48.71E-01,-4.8712(2) 关系,逻辑,数值(3) 900,100,mid(a,2,1),c(4)m1,2,3print m & 月是第二季度end select三(1) x=4 y=13(2) 10四4-1Private Sub Command1_Click()Dim num, a1, a2, a3 As Singlenum = Val(Text1) * 180 / 3.14a1 = Int(num)num = num - a1a2 = Int(num * 60)num = num * 60
10、- a2a3 = Format(num * 60, #.000)Print a1, a2, a3End Sub4-2Private Sub Command1_Click()Dim y As Integery = Val(Text1)If (y Mod 400 = 0 Or y Mod 4 = 0 And y Mod100 0) Then MsgBox y & 是闰年Else MsgBox y & 不是闰年End IfEnd Sub4-3Private Sub Command1_Click()Dim x, y, z, t As Integerx = Val(InputBox(input x:)y
11、 = Val(InputBox(input y:)z = Val(InputBox(input z:)If x y Then t = x: x = y: y = tIf y z Thent= y: y = z: z = t If x y Then t = x: x = y: y = tEnd IfPrint x, y, zEnd Sub4-4Private Sub Command1_Click()Dim nettime As Integer, money As Singlenettime = Val(InputBox(每月上网时数:, 上网费用)If nettime = -1 Then mon
12、ey = 0ElseIf nettime 10 Then money = 25ElseIf nettime 50 Then money = nettime * 2ElseIf nettime 100 Then money = nettime * 1.5ElseIf nettime 200 Then money = nettimeElse money = 200End IfIf money 0 Then MsgBox 该月上网费用为 & money &元实验五一BCBAC二(1)for x=1 to 10s*(1-1/x)(2)0t1E-6(3)jt(4)511 5三5-1Private Sub
13、 Command1_Click()Dim i, sum As Integersum = 0For i = 1 To 100sum = sum + iNext iPrint 1+2+.+100=; sumEnd Sub5-2Private Sub Command1_Click()Dim x, y As IntegerFor x = 0 To 20 For y = 0 To 33 If 5 * x + 3 * y + (100 - x - y) / 3 = 100 Then Print x, y, 100 - x - y End If Next yNext xEnd Sub5-3Private S
14、ub Command1_Click()Dim i As Integeri = 7DoIf i Mod 2 = 1 And i Mod 3 = 2 And i Mod 5= 4 And i Mod 6 = 5 And i Mod 7 = 0 Then Print i Exit DoElsei= i + 7End IfLoopEnd Sub5-4Private Sub Command1_Click()Dim x, y, z As IntegerFor x = 1 To 9 For y = 1 To 9 For z = 0 To 9 If 100 * x + 10 * x + z + 100 * y
15、 + 10 * z + z = 532 ThenPrint x, y, z End If Next z Next yNext xEnd Sub5-5Private Sub Command1_Click()Dim sum As Single, n As Integersum = 1Do While sum = 0.0001 ti = (-1) (i + 1) / (2 * i - 1) pi = pi + tii= i + 1LoopEnd Sub5-9Private Sub Command1_Click()Dim i, j, k As IntegerPrint 水仙花数有:For i = 1
16、To 9 For j = 0 To 9 For k = 0 To 9If i * 100 + j * 10 + k = i 3 + j 3+ k 3 ThenPrint i, j, k End If Next k Next jNext iEnd Sub5-10Private Sub Command1_Click()Dim i, j, k As Integerk = 0For i = 999 To 100 Step -1 For j = 2 To Int(Sqr(i) If i Mod j = 0 Then Exit For Next j If j = Int(Sqr(i) + 1 Then k
17、 = k + 1: Print i If k = 3 Then Exit ForNext iEnd Sub5-11Private Sub Command1_Click()Dim i, n, min, max As IntegerDim aver As Singlemin = 100max = 50For i = 1 To 20n= Int(Rnd * (99 - 51) + 51) Print n; If i Mod 5 = 0 Then Print If n max Then max = n If n Max Then Max = ia(i): iMax = iIf ia(i) min Th
18、en min = ia(i): imin = iNext iPrint max=; Max,imax=; iMaxPrint min=; min,imin=; iminPrint aver=; aver / 10End Sub6-2Private Sub Command1_Click()Dim ia(20), num(5) As IntegerDim Max, min, aver As Integer, iMax, iminAs IntegerFor i = 1 To 20 ia(i) = Int(Rnd * 101) Print ia(i); Select Case ia(i) Case I
19、s 60 num(1) = num(1) + 1Case60 To 69 num(2) = num(2) + 1 Case 70 To 79 num(3) = num(3) + 1 Case 80 To 89 num(4) = num(4) + 1 Case 90 To 100 num(5) = num(5) + 1 End SelectNext iPrintPrint 各分数段的人数分别是(059,6069,7079,8089,90100):For i = 1 To 5 Print num(i);Next iEnd Sub6-3Private Sub Command1_Click()Dim
20、a(10) As Integer, t%For i = 1 To 10a(i) = Int(Rnd * 51)Print a(i);Next iPrintFor i = 1 To 9For j = i + 1 To 10 Ifa(i) Max Then Max = ia(i, j): iMax = i: jmax = j Next j PrintNext iPrint max=; Max,imax=; iMax, jmax=; jmaxEnd Sub实验七一CCDAB DDAAA二(1)n!(2)1到n累加和(3)n是否是素数(4)冒泡排序(5)递归调用实现斐波那契数列(6)求最大公约数和最小公倍数三7-1Private Sub Command1_Click()Dim n, sum As Integern = Val(InputBox(n=?)sum = jsh(n)
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1