ImageVerifierCode 换一换
格式:DOCX , 页数:54 ,大小:83.17KB ,
资源ID:23258858      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/23258858.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(常见VB考试题型.docx)为本站会员(b****1)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

常见VB考试题型.docx

1、常见VB考试题型1输入半径,求圆面积和球体积。Private Sub Form_Load()Dim r As Single, s As Single, v As Singler = InputBox(请输入半径r:, 输入数据)s = 3.14 * r 2v = 4 / 3 * r 3 * 3.14Print 圆面积为:; sPrint 球体积为:; vMsgBox (圆面积为: & s & Space(2) & 球体积为: & v)End Sub2输入两个数存放在x和y中 ,比较大小,保证大数放在x中,小的数放在Y中。Private Sub Command1_Click()Print 比较前

2、:X = InputBox(请输入X)Y = InputBox(请输入Y)Print X=; X, Y=; YIf X Y Then Z = Y Y = X X = ZEnd If Print 比较后:Print X=; X, Y=; YEnd Sub3 判断一个整数的奇偶性Private Sub Form_Click()x = Val(InputBox(请输入一个数;)If x Mod 2 = 0 Then MsgBox (x & 是偶数)Else MsgBox (x & 是奇数)End IfEnd Sub4 帐号和密码Private Sub Command1_Click()If Text1

3、.Text = 12345 Then If Text2.Text = 12345 Then MsgBox 登录成功, 64 + 1, 登录 Else MsgBox 密码错误,请重新输入, 16 End IfElse MsgBox 用户不存在, 16 + 1, 登录End IfEnd Sub5 判断一个数是整数还是小数,如果是整数再判断其奇偶性 。 Private Sub Form_Click()x = InputBox(请输入一个数;)If InStr(1, x, .) = 0 Then If x Mod 2 = 0 Then MsgBox (x & 是整数,是偶数!) Else MsgBox

4、 (x & 是整数,是奇数!) End IfElse MsgBox (x & 是小数)End IfEnd Sub6 书店优惠售书Private Sub Command1_Click()Dim x As Single, y As Singlex = Val(Text1.Text)Select Case x Case Is = 100 y = x * 0.8 Case Is = 200 y = x * 0.7 Case Is = 300 y = x * 0.5 Case Else y = x * 0.3End SelectLabel3.Caption = y & 元End Sub7 设计一个计程车

5、收费程序Private Sub Command1_Click()X = Val(Text1.Text)Select Case X Case Is = 3 Label3.Caption = 6 Case Is = 30 Label3.Caption = 6 + (X - 3) * 1.5 Case Else Label3.Caption = 6 + 27 * 1.5 + (X - 30) * 2End SelectEnd Sub8 输入10个数,输出累加之和。Private Sub Command1_Click()Dim S As Single, i As Integer, x As Singl

6、eS = 0For i = 1 To 10x = Val(InputBox(请输入第 & i & 个数)Print 第 & i & 个数 & xS = S + xNext iPrint 十个数累加之和为 & SEnd Sub9 输入10个数,输出偶数之和。Private Sub Command1_Click()Dim S As Single, x As SingleDim n As Integer, i As IntegerS = 0For i = 1 To 10x = Val(InputBox(请输入第 & i & 个数)Print 第 & i & 个数 & xIf x Mod 2 = 0

7、ThenS = S + Val(x)End IfNext iPrint 十个数中偶数累加之和为 & SEnd Sub10 求S=1+2+3+100Private Sub Command1_Click()Dim I As Integer, S As LongS = 0For I = 1 To 100S = S + INext IPrint Tab(10); S=; SEnd Sub11 求S=1+3+5+99Private Sub Command1_Click()s = 0For i = 1 To 100 Step 2 s = s + iNext iPrint s=; sEnd Sub12 S=

8、1+22+32+102,计算并输出sPrivate Sub Command1_Click()s = 0For i = 1 To 10 s = s + i 2Next iPicture1.Print s=; sEnd Sub13 S=1+22+32+n2,问n为多少时,s的值大于100000?Private Sub Command1_Click()s = 0n = 0Do While s 10 (-5) S1 = 1 J = 1 Do While J = 10 (-5)S = S + (1 / x) * (-1) (n + 1)x = x * (n * 2) * (2 * n + 1)n = n

9、 + 1LoopPrint S=; SEnd Sub21 s=2+22+222+2222+22222+222222Private Sub Command1_Click()Dim s As Long, s1 As Long, i As Integer, j As Integers = 0For i = 1 To 6 s1 = 0 For j = 1 To i s1 = s1 + 2 * 10 (j - 1) Nexts = s + s1Next Print s=; sEnd Sub22 S=a+aa+aaa+aaaa(N个a)其中a是一个1,9的随机整数,N是一个5,10的随机整数。Privat

10、e Sub Command1_Click()Dim a As Integer, n As IntegerDim s As Long, s1 As Long, i As Integer, j As IntegerClsRandomizea = Int(9 * Rnd) + 1n = Int(6 * Rnd) + 5s = 0For i = 1 To n s1 = 0 For j = 1 To i s1 = s1 + a * 10 (j - 1) Next j s = s + s1Next i Print 当a=; a, n=; n; 时 Print Print s=; sEnd Sub23 S=

11、1+12+123+1234+12345+123456Private Sub Command1_Click()Dim s As Long, s1 As Long, i As Integer, j As Integers = 0s1 = 0For i = 1 To 6s1 = s1 * 10 + iPrint s1s = s + s1Next iPrint s=; ss = 0For i = 1 To 6 s1 = 0 For j = 1 To i s1 = s1 + j * 10 (i - j) Next j s = s + s1Next iPrint s=;sEnd Sub24 将一字符串逆序

12、输出Private Sub Command1_Click()Dim n As Integer, s1 As String, s2 As Strings1 = Text1.Texts2 = n = Len(Trim(Text1.Text)For i = n To 1 Step -1 s2 = s2 & Mid(s1, i, 1)Next iText2.Text = s2End Sub25 判断任给一大于3的整数是否是素数。Private Sub Command1_Click()Dim N As Integer, I As IntegerN = InputBox(请输入一个大于3的整数)For I

13、 = 2 To N - 1 If N Mod I = 0 Then Exit For End IfNext IIf N = I Then MsgBox (N & 是素数)Else MsgBox (N & 不是素数)End IfEnd Sub26 输出3100之间的素数输出Private Sub Command1_Click()Dim n As Integer, i As IntegerFor n = 3 To 100 For i = 2 To n - 1 If n Mod i = 0 Then Exit For End If Next i If i = n Then Print n End I

14、fNext nEnd Sub换行输出Private Sub Command2_Click()Dim n As Integer, i As IntegerDim m As Integerm = 0For n = 3 To 100 For i = 2 To n - 1 If n Mod i = 0 Then Exit For End If Next i If i = n Then m = m + 1 If m Mod 5 = 0 Then Print n Else Print n; End If End IfNext nEnd SubPrivate Sub Command2_Click()Dim

15、n As Integer, i As Integerdim m as inm = 0For n = 3 To 100 For i = 2 To n - 1 If n Mod i = 0 Then Exit For End If Next i If i = n Then m = m + 1 If m Mod 5 = 0 Then Print Tab(6 * m); n m = 0 Else Print Tab(6 * m); n; End If End IfNext nEnd Sub27 输出100999之间的水仙花数Private Sub Command1_Click()Dim I As In

16、teger, A As IntegerDim B As Integer, C As IntegerFor I = 100 To 999 A = Int(I / 100) B = Int(I / 10) - A * 10 C = I - A * 100 - B * 10 If A 3 + B 3 + C 3 = I Then Picture1.Print I; End IfNext IEnd Sub28陈婷的QQ密码是一个5位数。但因为有一段比较长的日子没上了,陈婷把这个密码给忘了。不过陈婷的生日是8月1日,她妈妈的生日是9月1日,她特别喜欢把同时是8l和9l的倍数用作密码。陈婷还记得这个密码的

17、中间一位(百位数)是l。你能设计一个程序帮她找回这个密码吗? Private Sub Command1_Click()陈婷密码:5位数,能被81,91整除,百位是1Dim i As Long, x As IntegerFor i = 10100 To 99199 x = i 100 Mod 10 If x = 1 Then If i Mod 91 = 0 And i Mod 81 = 0 Then MsgBox 密码是 & i End If End IfNext iEnd Sub29 百元买百鸡问题。假定小鸡每只5角,公鸡每只2元,母鸡每只3元。现在有100元钱要求买100只鸡(每种鸡至少一只

18、),编程列出所有可能的购鸡方案Option ExplicitPrivate Sub Command1_Click()Dim X As Integer, Y As IntegerDim z As Integer, I As IntegerI = 0For X = 1 To 100 For Y = 1 To 50 For z = 1 To 33 If X + Y + z = 100 And 0.5 * X + 2 * Y + 3 * z = 100 Then I = I + 1 Picture1.Print 方案 & I & :小鸡 & X & 只, _ & 公鸡 & Y & 只, & 母鸡 &

19、z & 只。 End IfNext z, Y, XEnd Sub30 鸡兔合笼共20只,脚46只问鸡几只?兔几只?Private Sub Command1_Click()Dim x As Integer, y As IntegerFor x = 1 To 20 For y = 1 To 20 - x If x + y = 20 And 2 * x + 4 * y = 46 Then Print 鸡 & x & 只 , 兔 & y & 只 End IfNext yNext xEnd Sub31 找出100之内的自然数对 。 (两数的和是某个自然数的平方,两数的差也是某数的平方)Private S

20、ub Command1_Click()For i = 1 To 99 For j = i + 1 To 100 If Int(Sqr(j - i) = Sqr(j - i) And Int(Sqr(j + i) = Sqr(j + i) Then Print i, j End If Next j Next iEnd Sub32 找出1000-9999之间的玫瑰花数。Private Sub Command1_Click()Dim i As IntegerDim a1 As Integer, a2 As IntegerDim a3 As Integer, a4 As IntegerFor i =

21、1000 To 9999 a1 = i 1000 a2 = i 100 Mod 10 a3 = i 10 Mod 10 a4 = i Mod 10 If a1 4 + a2 4 + a3 4 + a4 4 = i Then Print i End IfNext iEnd Sub33 猴子吃桃子。小猴在某天摘桃若干个,当天吃掉一半多一个;第二天吃了剩下的桃子的一半多一个;以后每天都吃尚存桃子的一半多一个,到第7天要吃时只剩下一个,问小猴共摘下了多少个桃子?Option ExplicitPrivate Sub Command1_Click()Dim X As Integer, I As Integ

22、erX = 1For I = 6 To 1 Step -1X = (X + 1) * 2Picture1.Print 第 & I; 天桃子数是: & X & 个。Next IEnd Sub34瓜农有西瓜1020个,每天能卖掉前一天剩下的总数的一半还多两个,问多少天能卖完。Option ExplicitPrivate Sub Command1_Click()Dim X As Integer, I As IntegerX = 1020I = 0 Do While X 0 X = X / 2 - 2 I = I + 1 LoopLabel4.Caption = 第 & I & 天能卖完.End Su

23、b35一球从10米高空落下,每次弹起高度为落下高度的40%,求第8次落下,小球经历的路程。Private Sub Command1_Click()Dim s As Single, h As Single, i As Integers = 10h = 10For i = 2 To 8 h = h * 0.4 s = s + h * 2 Next iPicture1.Print 球第八次落下经历的路程是:; s; 米End Sub36 输入十个数,输出其中的最大数和最小数Private Sub Command1_Click()Dim x As Single, i As IntegerDim max As Single, min As Singlex = Val(InputBox(请输入第1个数)Print xmax = x: min = xFor i = 2 To 10 x = Val(InputBox(请输入第 &

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1