已阅读5页,还剩44页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
adodc1.connectionstringadodc1.controlsourceprivate sub commandbutton1_click()sheet1.activatedim i as integerdim j as integer for i = 1 to 10 for j = 1 to 10 sheet1.cells(i, j) = i * j next j next i end subprivate sub command1_click()dim x as integer, y as integerx = 18: y = 15call value(x, y)print x=; y=; yend subprivate sub value(byval m as integer, byval n as integer)m = m + 2: n = n + 5print m=; m, n=; nend subprivate sub command1_click()if data1.recordset.recordcount = 0 thenmsgbox 没有记录elsedata1.recordset.movefirstend ifend subprivate sub commandp_click()if data1.recordset.recordcount = 0 thenmsgbox 没有记录elseif data1.recordset.bof thenmsgbox 这是第一条记录data1.recordset.movefirstelsedata1.recordset.movepreviousif data1.recordset.bof thendata1.recordset.movefirstmsgbox 这是第一条记录end ifend ifend ifend subprivate sub form_load()data1.connect = accessdata1.databasename = app.path + class.mdbdata1.recordsource = 学院表end subprivate sub command2_click()adodc1.recordset.movelastend subprivate sub command3_click()adodc1.recordset.movefirstadodc1.recordset.deleteend subprivate sub command1_click()text3.text = text1.text + text2.textend subprivate sub command2_click()adodc1.recordset.movenextif adodc1.recordset.eof then adodc1.recordset.movelast msgbox this is last contentend ifend subprivate sub commandbutton1_click()sheet1.activatedim i as integer, j as integer for i = 1 to 10 for j = 1 to 10 sheet1.cells(i, j) = i * j next j next i end subprivate sub userform_click()dim i as integer, j as integeri = 1: j = 2 print j; do while i = 100 print i; t = i i = i + j j = tloopend sub private sub form_activate()print 窗体1的activate时间被激发end subprivate sub command1_click() form2.showend subprivate sub command2_click()me.caption = 更改标题endend subprivate sub form_activate()print 窗体1的activate时间被激发end subprivate sub command1_click()form2.hideform1.showend subprivate sub command2_click() me.caption = 更改标题end subprivate sub command3_click()form1.clsform1.showend subprivate sub form_load()command1.caption = 复制end subdim temptext as stringprivate sub cmdcopy_click()temptext = text1.seltextif text1 then cmdpaste.enabled = trueelse: msgbox 请先清除文本end if end subprivate sub cmdcut_click()temptext = text1.seltextif temptext thentext1.seltext = cmdpaste.enabled = trueelsemsgbox 请先选中文本end ifend subprivate sub cmdpaste_click()text2.text = temptextend sub红绿灯dim path as stringprivate sub cmdgreen_click() picture1.picture = loadpicture(path + trffc10a.ico)end subprivate sub cmdred_click() picture1.picture = loadpicture(path + trffc10c.ico)end subprivate sub cmdyellow_click() picture1.picture = loadpicture(path + trffc10b.ico)end subprivate sub form_load() path = c:program filesmicrosoft visual studiocommongraphicsiconstrafficend sub选择题窗口private sub command1_click()dim ans as stringif option1.value = true then ans = aif option2.value = true then ans = bif option3.value = true then ans = cif option4.value = true then ans = d text1.text = ansend sub字体变化private sub check1_click() if check1.value = 1 then text1.fontbold = true else text1.fontbold = false end if end sub private sub check2_click() if check2.value = 1 then text1.fontitalic = true else text1.fontitalic = false end ifend sub private sub check3_click() if check3.value = 1 then text1.fontunderline = true else text1.fontunderline = false end if end sub private sub check4_click() if check4.value = 1 then text1.fontstrikethru = true else text1.fontstrikethru = false end if end sub 米粉调查private sub command1_click()dim msg as stringmsg = 您的孩子if option1.value = true then msg = msg + option1.captionif option2.value = true then msg = msg + option1.captionif option3.value = true then msg = msg + option1.captionmsg = msg + 使用过的米粉牌子有:if check1.value = 1 then msg = msg + check1.caption + if check2.value = 1 then msg = msg + check1.caption + if check3.value = 1 then msg = msg + check1.caption + if check4.value = 1 then msg = msg + check1.caption + text1.text = msgend sub增加索引private sub form_load()list1.additem 西游记list1.additem 傲慢与偏见list1.additem 水壶传list1.additem 王子复仇记list1.additem 白雪公主list1.additem 红楼梦list1.additem 灰姑娘list1.additem 牛虻cmddelete.enabled = falseend subprivate sub list2_click()cmddelete.enabled = (list2.listindex -1)end subprivate sub cmdadd_click()list2.additem list1.text end subprivate sub cmddelete_click()list2.removeitem list2.listindexcmddelete.enabled = (list2.listindex -1)end sub选择学历private sub combo1_click()text1.text = 你的学历是 & combo1.textend subprivate sub combo1_keypress(keyascii as integer) if keyascii = 13 then text1.text = 你的学历是 & combo1.text end if end subprivate sub form_load()combo1.additem 研究生combo1.additem 本科combo1.additem 大专combo1.additem 大专以下end subprivate sub form_load()text1.text = 0text2.text = 30label3.caption = 系统时间是: & timeend sub时间控件private sub timer1_timer()if val(text1.text) = 30 then endelse text1.text = val(text1.text) + 1 text2.text = 30 - val(text1.text) label3.caption = 系统时间: & timeend ifend sub三角形private sub command2_click()dim a as integer, b as integer, c as integera = val(txta.text): b = val(txtb.text): c = val(txtc.text)if a 0 and b 0 and c 0 thenif a + b c and a + c b and b + c a then picture.print 以 & a&; , & b&; , & c&; 为三边可以构成一个三角形else picture.print 以 & a&; , & b&; , & c&; 为三边不能构成一个三角形end ifend sub三角形面积private sub cmdshow_click() dim r as single, ans as single, pi as single pi = 3.14 r = val(text1.text) if r 0 then if check1.value = 1 then ans = 2 * pi * r list1.additem 圆周为 & ans end if if check2.value = 1 then ans = pi * r * r list1.additem 圆周为 & ans end if else list1.additem 非法数据 end ifend sub 键盘事件private sub text1_keypress(keyascii as integer) dim x as integer if keyascii = 13 then if len(text1.text) = 1 and text1.text = a and text1.text = z then x = asc(text1.text) if x asc(z) then text2.text = chr(x + 1) else text2.text = chr(x + 1 - 26) end if else text2.text = 数据非法! end if end if end sub自动拖放 p63private sub form_load()picture1.picture = loadpicture(app.path + moon02.ico)picture2.picture = loadpicture(app.path + moon04.ico)picture1.dragicon = loadpicture(app.path + moon03.ico)end subprivate sub picture2_dragdrop(source as control, x as single, y as single)picture1.picture = loadpicture(app.path + moon04.ico)picture2.picture = loadpicture(app.path + moon02.ico)end sub拖放国旗 p65dim flag1 as boolean, flag2 as booleanprivate sub form_dragdrop(source as control, x as single, y as single)if flag1 = true then image1.move x.y if x=shape2.left and x=shape2.top and y=shape2.left and x=shape2.top and y=shape2.top+shap2.height thenmsgbox 选错了! end ifend ifend subprivate sub form_load()image1.picture = loadpicture(app.path + flagflgusa02.ico)image2.picture = loadpicture(app.path + flagflguk.ico)end subprivate sub image1_mousedown(button as integer, shift as integer, x as single, y as single)flag1 = trueflag2 = falseimage1.drag 1image1.dragicon = loadpicture(app.path + flagflgusa02.ico)end subprivate sub image1_mouseup(button as integer, shift as integer, x as single, y as single)flag1 = falseimageq.drag 2end subprivate sub image2_mousedown(button as integer, shift as integer, x as single, y as single)flag2 = trueflag1 = falseimage2.drag1image2.dragicon = loadpicture(app.path + flagflguk.ico)end subprivate sub image2_mouseup(button as integer, shift as integer, x as single, y as single)flag2 = falseimage2.drag 2end subp68private sub mnucircle_click()shape1.shape = 3end subprivate sub muncross_click()shape1.fillstyle = 6end subprivate sub mundcross_click()shape1.fillstyle = 7end subprivate sub munsquare_click(index as integer)shape1.shape = 1end sub闹钟p160private sub command1_click()timer1.enabled = not timer1.enabledend subprivate sub timer1_timer()dim d as dated = text1.textif hour(time) = hour(d) and minute(time) = minute(d) then beepend sub根号运算 p161private sub command1_click() dim x as single, y as single x = val(text1.text) if x 0 then msgbox x不能小于0 else y = sqr(x) text2.text = str(y) end if end sub计算行李 p163private sub command1_click() dim x as single, y as single x = val(text1.text) if x 30 then y = 0 elseif x = 50 then y = (x - 30) * 10 else y = (x - 50) * 20 + 20 * 10 end if text2.text = yend sub判断年龄 p164private sub command1_click()if option1.value = true then if val(text1.text) 14 then msgbox hello,boy else msgbox hello,guy end ifelse if val(text1.text) 14 then msgbox hello,girl else msgbox hello,miss end ifend ifend sub计算器 p167private sub form_load()combo1.additem +combo1.additem -combo1.additem *combo1.additem /end subprivate sub command1_click() select case combo1.text case + text3.text = val(text1.text) + val(text2.text) case + text3.text = val(text1.text) - val(text2.text) case * text3.text = val(text1.text) * val(text2.text) case / if val(text2.text) 0 then text3.text = val(text1.text) / val(text2.text) else msgbox p被0除 text2.text = text2.setfocus end if end selectend sub求最大值和最小值 p169private sub command1_click() dim a as integer, b as integer a = val(text1.text) b = val(text2.text) if a b then max = a else max = b if a b then min = a else min = b msgbox max & 是最大值 & min & 是最小值end sub输入字母判断 p169private sub text1_keypress(keyascii as integer)if (keyascii asc(z) and (keyascii asc(z) then keyascii = 0end sub密码设置 p170private sub command2_click() if text1.text = or text2.text = then msgbox 请输入完整信息! else if text2.text 2008 then msgbox 密码错误! text1.text = text1.setfocus else msgbox text1.text & ,欢迎你! end if end ifend sub计算总分和平均分 p171private sub command1_click() dim sum as integer, n as integer if check1.value = 1 then sum = sum + val(text1.text): n = n + 1 if check2.value = 1 then sum = sum + val(text3.text): n = n + 1 if check3.value = 1 then sum = sum + val(text3.text): n = n + 1 if option1.value then text4.text = n & 门数总分: & vbcrlf & sum else if n 0 then text4.text = n & 门课平均分 & vbcrlf & sum / n end ifend sub排序 p172private sub command1_click() dim a as integer, b as integer, c as integer dim temp as integer a = val(text1.text) b = val(text2.text) c = val(text3.text) if a b then temp = a: a = b: b = temp if a c then temp = a: a = c: c = temp if b c then temp = b: b = c: c = temp text1.text = a text2.text = b text3.text = cend sub计算方程根 p172private sub command1_click() dim a as double, b as double, c as double dim delta as double dim x1 as double, x2 as double a = val(text1.text) b = val(text2.text) c = val(text3.text) if a 0 then delta = b * b - 4 * a * c if delter 0 then x1 = (-b + sqr(delta) / (2 * a) x2 = (-b - sqr(delta) / (2 * a) text4.text = x1= & chr(13) & chr(10) & x2= & x2 elseif delta = 0 then x1 = -b / (2 * a) text4.text = 两个相同的结果,x1=x2= & x1 else x1 = -b / (2 * a) x2 = sqr(-delta) / (2 * a) text4.text = x1= & x1 & + & x2 & i & chr(13) & chr(10) & x2= & x1 & - & x2 & i end if end if end sub计算3,5,7 p173private sub command1_click() dim x as integer x = val(text1.text) if x mod 3 = 0 and x mod 5 = 0 and x mod 7 = 0 then msgbox 能被3,5,7整除 elseif x mod 3 = 0 and x mod 5 = 0 and x mod 7 0 then msgbox 能被3,5整除 elseif x mod 3 = 0 and x mod 7 = 0 and x mod 5 0 then msgbox 能被3,7整除 elseif x mod 7 = 0 and x mod 5 = 0 and x mod 3 0 then msgbox 能被5,7整除 elseif x mod 3 = 0 then msgbox 能被5整除 elseif x mod 5 = 0 then msgbox 能被5整除 elseif x mod 7 = 0 then msgbox 能被7整除 else msgbox 不能被3,5,7任一数值整除 end ifend sub计算1到100 p179private sub command1_click()dim i as integer, sum as integersum = 0for i = 1 to 100sum = sum + inext itext1.text = sumend sub计算被3整除 p179private sub command1_click()dim x as integer, n as integerfor x = 1 to 200 if x mod 3 = 0 then print x; n = n + 1 if n mod 10 = 0 then print end if next x print end sub验证谷角猜想 p181private sub command1_click()dim x as integer, n as integerfor x = 3 to 200 step 3print x;n = n + 1if n mod 10 = 0 then print next x printend subprivate sub command1_click() dim n as integer cls n = val(inputbox(请输入一个正整数) print n; if n 0 then do while n 1 if n mod 2 = 1 then n = n * 3 + 1 else n = n / 2 end if print -; n; loop end if end sub随机数的平均数 p183private sub form_click()dim n as integer, x as integer, sum as integer n = fix(val(inputbox(请输入数据个数) do until n 0 if msgbox(输入错误,需要从新输入吗?, vbyesno) = vbyes then n = fix(val(inputbox(请输入数据个数) else exit sub end if loop sum = 0 for i = 1 to n x = int(rnd * 100) sum = sum + x print x: if i mod 10 = 0 then print next i print print n; 个数的平均值等于=; sum / n end sub阶乘p 186private sub command1_click() dim i as integer, s as double i = 1 do while i = 10 s = 1 for j = 1 to i s = s * j next j print i; !=; s i = i + 1 loopend sub九九乘法表 p187private sub command1_click() dim i as integer, j as integer for i = 1 to 9 for j = 1 to 9 picture1.print tab(10 * (j - 1); cstr(i); *; cstr(i * j); next j picture1.print next iend sub正弦函数 p188private sub command1_click() dim x as single, i as integer, j as integer dim sum as single, t as single, f as single x = val(text1.text) i = 1 do f = 1 for j = 1 to 2 * i - 1 f = f * j next j t = (-1) (i - 1) * x (2 * i - 1) / f sum = sum + t i = i + 1 loop until abs(t) max then max = grad next i print 最高分是; maxend sub穷举法 p190private sub form_load()dim a as integer, b as integer, c as integer, n as integerfor a = 1 to 4 for b = 1 to 4 for c = 1 to 4 if a b and b c and a c then print a * 100 + b * 10 + 10 n = n + 1 if n mod 5 = 0 then print end if next c next bnext aend sub素数判断 p193private sub command1_click() dim x as integer, i as integer x = val(text1) if x 1 then for i = 2 to x - 1 if x mod i = 0 then exit for next i if i = x then msgbox x & 是素数 else msgbox x & 不是素数 end if else msgbox x必须大于1 end ifend sub公约数 p194private sub command1_click() dim x as long, y as long, r as long, temp as long x = val(text1.text) y = val(text2.text) if x 1 or y 1 then msgbox 输入数据错误! else if x y then temp = x: x = y: y = temp do r = x mod y x = y y = r loop while r 0 text3.text = cstr(x) end if end sub迭代法求方程根 p196private sub command1_click() dim x0 as single, x1 as single x1 = val(inputbox(请输入x的初始值) do x0 = x1 x1 = x0 - (x0 * exp(x0) - 1) / (exp(x0) * (x0 + 1) loop until abs(x1 - x0) = a and ch = a and ch = z then if flag = false then flag = true
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年绿色科技创新孵化器项目可行性研究报告及总结分析
- 2025版设备施工员试题及答案
- 2024年四川阿坝教师招聘考试模拟题及答案
- 2025年城市固体废弃物处理系统可行性研究报告及总结分析
- 2025年体育健身中心建设项目可行性研究报告及总结分析
- 2025年特色小镇建设与运营可行性研究报告及总结分析
- 2025年城市安全与应急管理系统项目可行性研究报告及总结分析
- 2025年智能化农机设备市场可行性研究报告及总结分析
- 2025年绿色出行推广模式研究可行性研究报告及总结分析
- 2025年游戏行业新商业模式研究可行性研究报告及总结分析
- 墓地成本分析报告范文
- 《HTML5+CSS3网站设计基础教程(第3版)》ppt第5章 盒子模型
- 武松的主要事迹概括
- 光缆线路障碍点的定位
- 南瑞集团考试真题
- 小学数学结构化面试经典100题
- T、K、Y管节点焊缝超声波检验缺陷的判定
- ZJ70DB钻机绞车安装、操作及维护保养规程
- GB/T 34940.3-2017静态切换系统(STS)第3部分:确定性能的方法和试验要求
- GB/T 21198.5-2007贵金属合金首饰中贵金属含量的测定ICP光谱法第5部分:999‰银合金首饰银含量的测定差减法
- 现代优化算法-蚁群算法
评论
0/150
提交评论