信息技术学业水平测试VB操作复习题目含答案_第1页
信息技术学业水平测试VB操作复习题目含答案_第2页
信息技术学业水平测试VB操作复习题目含答案_第3页
信息技术学业水平测试VB操作复习题目含答案_第4页
信息技术学业水平测试VB操作复习题目含答案_第5页
已阅读5页,还剩57页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、信息技术学业水平测试VB操作复习题目含答案Private Sub Command1_Click() Dim h, m, s, ss As Integer ss = Val() h = ss 3600 m = (ss - h * 3600) 60 s = (ss - h * 3600) Mod 60 Label1.Caption = CStr(h) Label2.Caption = CStr(m) Label3.Caption = CStr(s)End SubVB操作一Private Sub Command1_Click() Dim x As String, y As String Dim i

2、As Integer Dim temp1 As String, temp2 As String y = For i = 1 To Len(Text1.Text) temp1 = Mid(x, i, 1) temp2 = 9 - temp1 y = y + temp2 Next i Text2.Text = yEnd SubVB操作一Private Sub Command1_Click() Dim i As Integer, a As Integer, b As Integer, c As Integer For i = 100 To 999 a = i 100 b = (i - a * 100

3、) 10 c = i Mod 10 If a 3 + b 3 + c 3 = i Then Print i Next iEnd subVB操作一Private Sub Command1_Click() Dim s(9) As Single For i = 0 To 9 s(i) = Val(InputBox(请输入一个数) Next i For i = 9 To 0 Step -1 Print s(i) Next iEnd SubVB操作一Private Sub Command1_Click() Dim a, b, c, max As Integer a = Val(Text1.Text) b

4、 = Val(Text2.Text) c = Val(Text3.Text) If a b Then max = a Else max = b If c max Then max = c Label3.Caption = CStr(max)End SubVB操作一VB操作二打不开Private Sub Command1_Click() Dim s As Single Dim q As Single Dim a As Single Dim b As Single Dim c As Single a = Val(InputBox(请输入边长a的值:) b = Val(InputBox(请输入边长b

5、的值:) c = Val(InputBox(请输入边长c的值:) q = (a + b + c) / 2 s = Sqr(q * (q - a) * (q - b) * (q - c) Print sEnd SubVB操作三Private Sub Command1_Click() Dim year As Integer year = Val(InputBox(请输入年号:) If (year Mod 4 = 0) And (year Mod 100 0) Or (year Mod 400 = 0) Then Print 是闰年 Else Print 不是闰年 End If End SubVB操

6、作三Private Sub Command1_Click() Dim a As Integer, b As Integer Dim bai As Integer, shi As Integer Dim g As Integer a = Val() bai = a 100 shi = (a - bai * 100) 10 g = a Mod 10 b = g * 100 + shi * 10 + bai = CStr(b)End SubVB操作三Private Sub Command1_Click() Dim x As Single, y As Single a = 3: b = -5 x =

7、Val(InputBox(请输入x的值) If x = 0 Then X1 = (-b + Sqr(p) / (2 * a) X2 = (-b - Sqr(p) / (2 * a) Print X1=; X1 Print X2=; X2 Else Print 该方程无实数根 End IfEnd SubVB操作三Private Sub Command1_Click() Dim Wuyuan As Integer Dim Yiyuan As Integer Dim Wujiao As Integer For Wuyuan = 1 To 20 For Yiyuan = 1 To 100 Wujiao

8、 = 100 - Wuyuan - Yiyuan If Wuyuan * 5 + Yiyuan * 1 + Wujiao * 0.5 = 100 Then Print Wuyuan= & Wuyuan & ,Yiyuan= & Yiyuan & ,Wujiao= & Wujiao End If Next Yiyuan Next Wuyuan End SubVB操作四Private Sub Command1_Click() Dim x As Single Dim cost As Single x = Val(InputBox(请输入苹果公斤数:) If x c) And (a + c b) An

9、d (b + c a) Then Let Text4.Text = OK Else Let Text4.Text = NO End IfEnd SubVB操作四Private Sub Command1_Click() Dim i, a, b As Integer For i = 100 To 999 a = i 100 b = (i - a * 100) 10 c = i Mod 10 If a * a * a + b * b * b + c * c * c = i Then Print CStr(i) End If Next iEnd SubVB操作五Private Sub Command1

10、_Click() Dim h, x, y As Single Let x = Val(Text1.Text) Let h = Val(Text2.Text) Let Text3.Text = yEnd SubVB操作五Private Sub Command1_Click() Dim a As Integer Dim b As Integer Dim t As Integer a = Val(Text1.Text) b = Val(Text2.Text) t = a a = b b = t Text1.Text = a Text2.Text = bEnd SubVB操作五Private Sub

11、Command1_Click() Dim n, i As Long Dim yes As Boolean Let n = Val(Text1.Text) Let yes = True For i = 2 To n 2 If n Mod i = 0 Then Let yes = False End If Next i If yes Then Let Text2.Text = yes Else Let Text2.Text = no End IfEnd SubVB操作五Private Sub Command1_Click() Dim r, s As Single r = Val() s = pi

12、* r * r T2.Text = sEnd SubVB操作五Private Sub Command1_Click()End SubVB操作六Private Sub Command1_Click() Dim a As Integer a = Val() If a Mod 2 = 0 Then Label1.Caption = 偶数 Else Label1.Caption = 奇数 End IfEnd SubVB操作六Private Sub Form_Click() Dim i As Integer Dim j As Integer Print For i = -3 To 3 Print Tab

13、(3); For j = 1 To 3 - Abs(i) Print *; Next Print * NextEnd SubVB操作六Private Sub Command1_Click() Dim s As Single s计算存款 Dim y As Integer y计算年份 Dim r As Single r是年利率 s = 1000 y = 0 r = Val(InputBox(输入年利率, 数据输入框) Do While s = 2000 y = y + 1 s = s * (1 + r) Loop Print y; 年以后,存款可以达到2000元 End SubVB操作六Priva

14、te Sub Command1_Click() Dim tz As Integer tz是桃子数 Dim ts As Integer ts是天数 tz = 1 For ts = 1 To 9 tz = (tz+1)* 2 Next ts Print 最初共有桃子 & tzEnd Sub倒推:第10天:1个第9天:4个第8天:10个第7天:22个。第1天:?设今天X个,剩下为Y个(明天)那么Y=X-(1/2*X+1)=1/2*X-1则X=(Y+1)*2VB操作六Private Sub Form_Load() Timer1.Interval = 1000 Label1.Caption = End

15、SubPrivate Sub Timer1_timer() Label1.Caption = TimeEnd SubVB操作七Private Sub Command1_Click() Dim x As Integer Dim s As Integer Dim i As Integer For i = 1 To 10 x = Val(InputBox(NO. & i) s = s + x Print CStr(x) Next i Print total: & s End SubVB操作七Private Sub Command1_Click() Dim w As Integer w是行李重量 Di

16、m pj As Integer pj是机票价格 Dim fy As Single w = Val(Text1.Text) pj = Val(Text2.Text) If w = 20 Then fy = 0 Else End If Text3.Text = fyEnd SubVB操作七Private Sub Command1_Click() Dim x As Single x = Val(InputBox(请输入x的值!) If x 50 Then y = 0.8 * x Else If x a(j) Then a(0) = a(i) a(i) = a(j) a(j) =a(0) End If

17、 Next j Next i For i = 1 To 10 Print CStr(a(i) Next iEnd SubPrivate Sub Command1_Click() Dim x As Integer, y As Integer x = Val(InputBox(请输入x的值:) If x=0 Then y = x Else y= -x End If Text1.Text = yEnd SubPrivate Sub Command1_Click() Dim x As Long For x = 67008 To 67998 Step 10 If (x Mod 67 = 0) Or (x

18、 Mod 78 = 0) Then Print x End If next xEnd SubPrivate Sub Form1_Click() Dim tz As Single, sg As Single Dim bz As Single tz = Val(InputBox(请输入您的体重:) sg = Val(InputBox(请输入您的体重:) bz = tz / sg 2 If bz 25 Then MsgBox (您的身材偏胖,需要加强锻炼!) Else If Then MsgBox (您的身材偏瘦,需要补充营养!) Else MsgBox (您的身材真棒!) End If End I

19、fEnd SubVB操作九Private Sub Command1_Click() x = Val(Text1.Text) If x Mod 3 = 2 Then If = 3 Then If Then Print End If End If End IfEnd Sub x mod 5 x mod 7=4 xPrivate Sub Form_Click() Dim p As Integer 变量p保存人口 Dim n As Long n = 0 Do While p = p * n = Loop Print n= & CStr(n)End Sub p=14 p=20 (1+0.04) n+1P

20、rivate Sub Command1_Click() Dim s As Integer Dim a As Integer Dim b As Integer Dim k As Integer s = 0 a = 1 b = 1 For k = 1 To 10 s = s + a / b a = s = b = Next k Print sEnd Sub a = a+b s = s+b/a b = a+b Private Sub Command1_Click() Dim i As Integer Dim s As Integer i = 1 s = 0 Do While i 1500 Print

21、 N= & CStr()End Sub n n+20 n-20VB操作十Private Sub Command1_Click()Dim S1 As Single, S2 As Single Dim V1 As Single, V2 As Single Dim T As Single S1 = Val(InputBox(请输入王晓珊家离学校的距离:) V1 = Val(InputBox(请输入王晓珊步行速度:) V2 = Val(InputBox(请输入李明步行速度:) T = S2 = * T Print End Sub s1/v1 v2 s2Public Function Fac(a As

22、Integer) As IntegerIf a = 1 Then Fac = Else Fac = a * (a - 1)End IfEnd FunctionPrivate Sub Command1_Click() Dim S As Integer S = Fac(3) + Fac() + Fac(7) Print S= & CStr(S)End Sub 1 Fac 5Public Function S(n As Integer) As Integer If n = 1 Then S = Else S = + S(n - 1) End IfEnd FunctionPrivate Sub Com

23、mand1_Click() Dim Sum As Integer Sum = S() Print Sum= & CStr(Sum)End Sub 1 n 100Private Sub Command1_Click() Dim L As Integer Dim chang As Integer Dim kuai As Integer Dim s As Integer Dim smax As Integer smax = 0 L = InputBox(请输入一条铁丝的长度:) For chang = 1 To L 2 For kuai = 1 To L 2 - chang s = If Then

24、smax = s End If Next kuai Next chang Print End Sub chang*kuai ssmax smaxPrivate Sub Command1_Click() Dim H As Single, L As Single Dim S As Single, Home As Single Home = Val(InputBox(请输入一个起始高度:) H = Home S = 0 Do L = 0.7 * S = S + H + L H = Loop While L = Home / 1000 Print End Sub H L S第11套不做,打不开VB操作

25、十二Private Sub Command1_Click() Dim t As Single 定义变量t,值由文本框Text1读入 t = Val() If Then Label1.Caption = 超重!不能参赛! Else Label1.Caption = 合格,可以参赛! End Sub t60 EndifPrivate Sub Command1_Click() Dim Cj As Single 定义变量Cj,值由文本框Text1读入 Cj = Val() If Cj 60 Then Label1.Caption = 不及格 End If If Cj = 60 Then Label1.

26、Caption = 良好 End If If Cj = 85 Then Label1.Caption = 优秀 End IfEnd Sub And Cj 85Private Sub Form_Click() Dim s As Single s变量用于存放计算结果 Dim p As Single Dim i As Integer 定义一个循环变量 给s赋初值 s = 给p赋初值 p = For i = 1 To 8 p = p * i s = Next i Print s=; CStr(s)End Sub 0 1 s+pPrivate Sub Form_Click() Dim s As Inte

27、ger 变量s存放和Dim n As Integern = 为n赋初值s = 为s赋初值Do While s 500 n = n + 1 s = Loop Text1.Text = CStr(n - 1)End Sub 0 0 s+n 0 0 =500Private Sub Form_Click()Dim s As Integer 变量s存放和 Dim n As Integers = 为s赋初值n = 为n赋初值Do n = n + 1 s = s + nLoop While s 500Text1.Text = CStr(n)End SubVB操作十三Private Sub Command1_

28、Click() Dim a As Integer Dim i As Integer a = For i = 1 To Step 1 a = Next i Text1.Text = CStr() End Sub 0 100a+i aPrivate Sub Command1_Click()Dim a As IntegerDim i As Integera = 1For i = 1 To Step 1 a = Next i Text1.Text = CStr()End Sub 7 a*i aPrivate Sub Form_Click()Dim s As Single 定义变量s为单精度型Dim i

29、 As Integer 定义循环变量 s = For i = 1 To Step 1 s = s + Next i Print s=; CStr(s)End Sub 0 100 1/iPrivate Sub Form_Click() Dim p As Single 变量p保存年产值 Dim n As Integer 整型变量n为所求年数 n = 0 Do While p 4000 p = p * n = Loop Print n=; CStr(n)End Sub p=2000 (1+0.05) n+1Private Sub Form_Click() Dim s As Single Dim i

30、As Integer s = For i = 1 To Step 1 If i Mod 2 0 Then s = s + 1 / i Else s = End If Next i Print s=; CStr(s)End Sub 0 100 s = s - 1 / iVB操作十四Private Sub Command1_Click()Dim i As Integer 定义i为整型变量 Dim j As Integer 定义j为整型变量 For i = 1 To 6 Step 1 For j = 1 To Step 1 Print Next Print Next iEnd Sub i “”; jPrivate Sub Command1_Click() Dim a(9) As Integer Dim s As Single Dim i As Integer s = 0 Randomize For i = 0 To Step 1 a(i) = Int(Rnd * 100) Print a(i) Next i For i = 0 To 9 s = Print 这10个自然数

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论