




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Private Sub Command1_Click() Dim h, m, s, ss As Integer ss = Val(Text1.Text) 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 As Integ
2、er Dim temp1 As String, temp2 As String x = Text1.Text 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 -
3、a * 100) 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.
4、Text) b = 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
5、(请输入边长b的值:) 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 不是闰年不是闰年
6、End If End SubVB操作三Private Sub Command1_Click() Dim a As Integer, b As Integer Dim bai As Integer, shi As Integer Dim g As Integer a = Val(Text1.Text) bai = a 100 shi = (a - bai * 100) 10 g = a Mod 10 b = g * 100 + shi * 10 + bai Text2.Text = CStr(b)End SubVB操作三Private Sub Command1_Click() Dim x As
7、Single, y As Single a = 3: b = -5 x = 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
8、= 1 To 20 For Yiyuan = 1 To 100 Wujiao = 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 A
9、s Single x = Val(InputBox(请输入苹果公斤数:) If x c) And (a + c b) And (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 The
10、n Print CStr(i) End If Next iEnd SubVB操作五操作五Private Sub Command1_Click() Dim h, x, y As Single Let x = Val(Text1.Text) Let h = Val(Text2.Text) Let y = x - (h / 100) * 0.5 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)
11、 b = Val(Text2.Text) t = a a = b b = t Text1.Text = a Text2.Text = bEnd SubVB操作五Private Sub 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.T
12、ext = no End IfEnd SubVB操作五Private Sub Command1_Click() Const pi = 3.14 Dim r, s As Single r = Val(T1.Text) s = pi * r * r T2.Text = sEnd SubVB操作五Private Sub Command1_Click()Form1.Caption = Text1.TextEnd SubVB操作六操作六Private Sub Command1_Click() Dim a As Integer a = Val(Text1.Text) If a Mod 2 = 0 Then
13、 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(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
14、 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操作六Private 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 Su
15、b倒推:倒推:第第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 SubPrivate Sub Timer1_timer() Label1.Caption = TimeEnd SubVB操作七操作七Private Sub Command1_Click() Dim x As
16、 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是行李重量 Dim pj As Integer pj是机票价格 Dim fy As Single w = Val(Text1.Text) pj = Val(Text2.Text) If w = 20
17、Then fy = 0 Else fy = (w - 20) * pj * 0.015 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 16.67 Label1.Caption = 飞船挣脱太阳引力飞出太阳系 case is =11.19 Label1.Caption = 飞船离开地球的控制,围绕太阳转 case is =7.91 Label1.Caption =
18、飞船绕地球似做匀速圆周运动 Case Else Label1.Caption = 输入数据错误! End selectEnd SubPrivate Sub Command1_Click() Dim a(10) As Integer For i = 1 To 10 a(i) = Int(Rnd * 1000) Next i For i = 1 to 9 For j = i+1 to 10 If a(i) a(j) Then a(0) = a(i) a(i) = a(j) a(j) =a(0) End If Next j Next i For i = 1 To 10 Print CStr(a(i)
19、 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 Mod 78 = 0) Then Print x End If next xEnd Sub
20、Private 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 bz18.5 Then MsgBox (您的身材偏瘦,需要补充营养!) Else MsgBox (您的身材真棒!) End If End IfEnd SubVB操作九操作九Private Sub Command1_Cl
21、ick() 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+1Private Sub Command1_Click() Dim
22、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 N= & CStr()End Sub n n+20 n
23、-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 Integer) As IntegerIf a =
24、 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 Command1_Click() Dim Sum
25、 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 smax = s End If N
26、ext 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操作十二操作十二Private Sub
27、 Command1_Click() Dim t As Single 定义变量t,值由文本框Text1读入 t = Val() If Then Label1.Caption = 超重!不能参赛! Else Label1.Caption = 合格,可以参赛! End Sub text1.text 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.Ca
28、ption = 良好 End If If Cj = 85 Then Label1.Caption = 优秀 End IfEnd Sub text1.text 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
29、s As Integer 变量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
30、Sub Command1_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 定义
31、变量s为单精度型Dim i 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
32、Single Dim i 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
33、 iEnd Sub i “”; jPrivate Sub Command1_Click() Dim a(9) As Integer Dim s As Single Dim i As Integer Me.Cls 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个自然数的平均值=; s / 10End Sub 9 s+a(i) Next iPrivate Sub Form_Click() Dim Ji As Integer Ji变量表示鸡的个数 Dim Tu As Integer Tu变量表示兔的个
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025北京市疾病预防控制中心招聘13人(第三批)考试备考题库及答案解析
- 邛崃市2025年公开考核招聘急需紧缺教育人才(20人)考试备考题库及答案解析
- 2025河南开封市万岁山游览区有限公司招聘备考题库及答案解析
- 2025贵州平塘县考调县教育局下设事业单位工作人员和县城学校教师115人考试备考题库及答案解析
- 婚庆公司策划师方案评审管理制度
- 2025年有毒物质危害实践考核答案及解析
- 2025年临床医学综合考核模拟试卷答案及解析
- 地铁工程资料标准化管理措施
- 部编版六年级语文下册学习反馈计划
- 九年级上学期语文多媒体教学计划
- 招生代理授权合同范本
- 2025年广西玉林产业投资集团有限公司社会招聘5人笔试备考题库及答案解析
- 《质量管理与可靠性》课件-第4章 质量检验
- 定额〔2025〕2号文-关于发布2020版电网技术改造及检修工程概预算定额2024年下半年价格
- 消防验收规范标准(最新完整版)19844
- 教研工作手册
- 独树一帜的中国画(课堂PPT)
- 制钵机的设计(机械CAD图纸)
- 生产设备控制程序
- LCM不良命名规范
- 《融资租赁业务介绍》PPT课件.ppt
评论
0/150
提交评论