




已阅读5页,还剩32页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第一题Dim s As StringPrivate Sub Command1_Click() Open App.Path & in4.dat For Input As #1 s = Input(LOF(1), #1) Close #1 Text1.Text = sEnd SubPrivate Sub Command2_Click() Dim m As Integer If Len(s) = 0 Then MsgBox 请先使用“读数据”功能! Else If Text1. SelLength = 0 Then MsgBox 请先选中文本! Else t = For i = 1 To Text1.SelLength c = Mid(Text1.SelText, i, 1) If c Then t = t + c Else x = t If InStr(x, o) 0 And InStr(x, n) 0 Then m = m + 1 End If t = End If Next i text2 = Str(m) End If End IfEnd Sub第二题Private Sub Command1_Click() Dim k As Integer Open App.Path & in5.dat For Input As #1 For k = 1 To 100 Input #1, a(k) Text1 = Text1 + Str(a(k) + Space(2) Next k Close #1End SubPrivate Sub Command2_Click() Dim b(100) As Integer num = 0 If Len(Text1.Text) = 0 Then MsgBox 请先执行“读数据”功能! Else考生编写(功能:生成存放素数的数组 b ) 注意:请务必将数组 b 的元素个数存入变量 num 中num = 1 For i = 1 To 100 For j = 2 To Sqr(a(i) If a(i) Mod j = 0 Then Exit For End If Next j If j Sqr(a(i) Then b(num) = a(i) num = num + 1 End If Next i以下程序段将 b 数组的内容显示在Text2中 For i = 1 To num-1 Text2.Text = Text2.Text + Str(b(i) + Space(2) Next i End IfEnd SubPrivate Sub Form_Unload(Cancel As Integer) Open App.Path & out5.dat For Output As #1 Print #1, Text2.Text Close #1End Sub第三题在控件上右击属性第四题Private Sub menu2_Click()menu1.Enabled = TrueEnd Sub第五题第一小题(1)Dim a(10) As IntegerPrivate Sub Form_Load() For i = 1 To 10 a(i) = Int(Rnd * 100) NextEnd SubPrivate Sub Command1_Click() x = a(1) y = a(1) For i = 2 To 10 If Option1.Value = True Then If a(i) x Then x = a(i) End If ElseIf a(i) y Then y = a(i) End If Next i If Option1.Value = True Then Label2.Caption = x Else Label2.Caption = y End IfEnd Sub第二小题(2)Private Sub List1_DblClick() Call MoveItem(List1, List2)End SubPrivate Sub Command1_Click() Call MoveAllEnd SubPublic Sub MoveItem(L1 As ListBox, L2 As ListBox) L2.AddItem L1.Text L1.RemoveItem L1.ListIndexEnd SubPublic Sub MoveAll() For i = 0 To List1.ListCount - 1 List2.AddItem List1.List(i) NextEnd Sub第五题Dim a(7, 7) As IntegerPrivate Sub Form_Load() readEnd SubPublic Sub read() Open App.Path & Data5.txt For Input As #1 Do While Not EOF(1) For i = 1 To 7 For j = 1 To 7 Input #1, a(i, j) Next j Next i Loop Close #1End SubPublic Sub Save() Open App.Path & out5.txt For Output As #1 Print #1, lblFirst.Caption, lblSecond.Caption Close #1End SubPrivate Sub Command1_Click() Dim Sum As Long N = 7 Counter = 0 Sum = 0 =考生编写程序开始= For i = 1 To N For j = 1 To N If i = j Or i + j = 8 Then If a(i, j) Mod 3 = 0 Then Counter = Counter + 1 Sum = Sum + a(i, j) End If End If Next j Next i lblFirst.Caption = Counter lblSecond.Caption = Sum =考生编写程序结束= SaveEnd Sub第六题注意:时钟的interval属性设置为 300Dim flag As IntegerPrivate Sub Cmd_Click(Index As Integer) If Index = 2 Then End Else Image1.Picture = LoadPicture(yellow.ico) flag = Index Timer1.Enabled = True End IfEnd SubPrivate Sub Timer1_Timer() Select Case flag Case 0 Image1.Picture = LoadPicture(green.ico) Timer1.Enabled = False Case 1 Image1.Picture = LoadPicture(red.ico) Timer1.Enabled = False End SelectEnd Sub第七题第八题Private Sub Form_Click()Label1.Visible = TrueEnd SubPrivate Sub Form_Load()Form1.Caption = 标签End Sub第九提Private Sub Command1_Click() Call ShowName(Command1)End SubPrivate Sub Label1_Click() Call ShowName(Label1)End SubPrivate Sub ShowName(c As Control) If TypeOf c Is CommandButton Then Label2.Caption = 单击 & Command1.Caption End If第十题注意,时钟interval设置为500Private Sub Form_Load() Picture1(0).Left = 0 Picture1(0).Top = 100 For k = 1 To 7 Picture1(k).Visible = False NextEnd SubPrivate Sub Command1_Click() Timer1.Enabled = TrueEnd SubPrivate Sub Command2_Click() Timer1.Enabled = FalseEnd SubPrivate Sub Timer1_Timer() Static i As Integer Picture1(i).Visible = False i = i + 1 If i = 7 Then i = 0 End If Picture1(i).Visible = TrueEnd Sub第十三题第十四题 第十五题第十六,七题Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)End SubPrivate Sub Text2_Change() If Check1.Value = 1 Then Text3.PasswordChar = Else Text3.PasswordChar = # End If Text3.Text = Text2.TextEnd SubPrivate Sub Command1_Click() Text1.Enabled = true Text1.SetFocusEnd SubPrivate Sub Command2_Click() If Text1.Enabled = False Then MsgBox 请先使用“输入密码”功能! Else If Text1 abc Then n = n + 1 If n = 3 Then MsgBox 三次密码输入错误,你无权进入本系统! End Else MsgBox 第 + Str(n) + 次密码输入错误,请重试! Text1 = Text1.SetFocus End If Else Text1.Enabled = False Text1 = form1.Hide form2.Show End If End IfEnd SubForm2:Private Sub Command1_Click() Form2.Hide Form1.ShowEnd Sub第十八题Option Base 1Dim s As StringPrivate Sub Command1_Click() Open App.Path & in4.dat For Input As #1 s = Input(LOF(1), #1) Close #1 Text1.Text = sEnd SubPrivate Sub Command2_Click() Dim m As Integer If Len(s) = 0 Then MsgBox 请先使用“读数据”功能! Else If Text1.sellength = 0 Then MsgBox 请先选中文本! Else t = For i = 1 To Text1.SelLength c = Mid(Text1.SelText, i, 1) If c Then t = t + c Else If t = the Then m = m + 1 End If t = End If Next i text2 = Str(m) End If End IfEnd Sub第十九题Option Base 1Dim a(100) As Integer, num As IntegerPrivate Sub Command1_Click() Dim k As Integer Open App.Path & in5.dat For Input As #1 For k = 1 To 100 Input #1, a(k) Text1 = Text1 + Str(a(k) + Space(1) Next k Close #1End SubPrivate Sub Command2_Click() Dim b(100) As Integer num = 0 If Len(Text1.Text) = 0 Then MsgBox 请先执行“读数据”功能! Else 考生编写(功能:生成 b 数组,且按从小到大顺序排序) 注意:请务必将数组 b 的元素个数存入变量 num 中 以下程序段将已排序的 b 数组显示在Text2中 For i = 1 To num Text2.Text = Text2.Text + Str(b(i) + Space(2) Next i End IfEnd SubPrivate Sub Form_Unload(Cancel As Integer) Open App.Path & out5.dat For Output As #1 Print #1, Text2.Text Close #1End Sub第二十题第二十一题Private Sub Form_Click()n = InputBox(请输入, 等级考试, Basic)End Sub第二十二题Private Sub Command1_Click() Dim n As Integer Dim b As Integer Dim a(3) As Integer s = RTrim(Text1.Text) n = Len(Text1.Text) For i = 1 To n b = a(Mid(s, i, 1) Select Case Asc Case 48 To 57 a(0) = a(0) + 1 Case 65 To 90 a(1) = a(1) + 1 Case 97 To 122 a(2) = a(2) + 1 End Select Next For i = 0 To 2 Label = a(i) NextEnd SubPrivate Sub remove(La As ListBox, Lb As ListBox) For i = 0 To la.listcount - 1 Lb.AddItem la. List(i) Next la.ClearEnd SubPrivate Sub Command1_Click() Call remove(List1, List2)End SubPrivate Sub Command2_Click() Call remove(List2, List1)End Sub第二十四题Dim a(10) As IntegerPublic Sub Save() Open App.Path & out5.txt For Output As #1 Print #1, Label4.Caption Close #1End SubPrivate Sub Command1_Click() Open App.Path & Data5.txt For Input As #1 Do While Not eof(1) For i = 1 To 10 Input #1, a(i) s = s & a(i) Next i Loop Close #1 Label2.Caption = sEnd SubPrivate Sub Command2_Click()=以下考生编写程序开始=For i=1 to 9 For j =i+1 to 10 If a(i)a(j) then t=a(i) a(i)=a(j) a(j)=t end if next jnext i=考生编写程序结束= For i = 1 To 10 s = s & Str(a(i) Next i Label4.Caption = s SaveEnd Sub第二十五,六题Private Sub HScroll1_Change()End SubPrivate Sub Form_Load()End SubPrivate Sub List1_Click()HS.Width = List1.TextEnd Sub 第二十七题Private Sub Form_Load() Load meEnd SubPrivate Sub Option1_Click(Index As Integer) Dim n As Integer n = Val(Text1.Text) Select Case Index Case 0 Text2.Text = f1(n) Case 1 Text2.Text = f1(n + 2) End SelectEnd SubPublic Function f1(n As Integer) As Long Dim x As Long x = 1 For i = 1 To n x = x * iNext f1 = x End Function第二十八题Private Sub Form_Load() Open App.Path & in4.txt For Input As #1 Line Input #1, s Text1.Text = s Close #1End SubPrivate Sub Command1_Click() Dim n As Integer s = Text1.Text s1 = RTrim(Text2.Text) Do p = InStr(s1, s) If p 0 Then n = n + 1 s = Mid(s, p + 1) Loop While p = 0 Label3.Caption = nEnd Sub第二十九题Private Function isprime(a As Integer) As Boolean Dim flag As Boolean flag = True b% = 2Do While b% = Int(a / 2) And flag If Int(a / b%) = a / b% Then flag = False Else b% = b% + 1 End If Loop isprime = flagEnd FunctionPrivate Sub C1_Click()Dim x As Integerx = 17999Do While x b(j) then T=b(i) B(i)=b(j) B(i)=t End if Next j Next i以下程序段将已排序的 b 数组显示在Text2中 For i = 1 To num Text2.Text = Text2.Text + Str(b(i) + Space(2) Next i End IfEnd SubPrivate Sub Form_Unload(Cancel As Integer) Open App.Path & out5.dat For Output As #1 Print #1, Text2.Text Close #1End Sub第三十四题Dim flag As IntegerPrivate Sub Form_Load() flag = 0End SubPrivate Sub Command1_Click() If Command1.Caption = 移动 Then Timer1.Enabled = ? Command1.Caption = 暂停 Else Timer1.Enabled = False Command1.Caption = 移动 End If End SubPrivate Sub Command2_Click() EndEnd SubPrivate Sub Timer1_Timer() Select Case flag Case Is = 0 Label1.Left = Label1.Left ? 100 If Label1.Left + Label1.Width = Form1.Width Then flag = 1 Case Is = 1 Label1.Left = Label1.Left ? 100 If Label1.Left = 0 Then flag = 0 End Select End Sub第三十五题设置列表框的sorted属性为true第三十六题Option Base 1Dim a(30) As IntegerPrivate Sub Cmd1_Click() Open App.Path & in3.dat For Input As #1 For m = 1 To 30 Input #1, a(m) Text1 = Text1 + Str(a(m) + Space(2) Next m Close #1 End SubPrivate Sub Cmd2_Click() Dim num As Integer, n As Integer num = InputBox(请输入待查找的数) If num / 2 ? Fix(num / 2) Then MsgBox 输入数为奇数,请重输!, , 检查 Exit Sub End If If num a(30) Then Text2.Text = Str(num) + 已超出所给数值范围 Exit Sub End If For n = 1 To 30 If a(n) = ? Then Text2.Text = Str(num) + 是数组中的第 + Str(n) + 个值 Exit For End If Next n If n ? 30 Then Text2.Text = Str(num) + 不存在于数组中 End IfEnd Sub第三十七题option Base 1Dim a(20, 3) As IntegerPrivate Sub Command1_Click() Open App.Path & in4.dat For Input As #1 For i = 1 T
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 中国邮政2025萍乡市秋招法律事务岗位高频笔试题库含答案
- 家庭装饰装修合同
- 楼顶灯箱施工方案
- 2025年VTE预防及护理考题及答案
- 幼儿园防拐骗应急预案总结
- 荆州木屋酒店施工方案
- 中国邮政2025长沙市秋招数据分析岗位高频笔试题库含答案
- 门岗聘用合同范本
- 吉安市烟草公司2025秋招综合管理类岗位面试模拟题及答案
- 中国邮政2025攀枝花市秋招信贷审查岗位高频笔试题库含答案
- 2025年中国道教协会招聘笔试备考题库(带答案详解)
- (高清版)建筑楼盖结构振动舒适度技术标准JGJ_T 441-2019
- 电气系统调试方案
- 呋喃树脂msds
- 福建省机关事业单位工勤人员技术等级岗位考核公共课
- 落实乡村振兴战略山核桃产业振兴五年行动方案
- 中国五矿集团供应商准入承诺书
- 2021年《红高梁模特队》台词(赵本山1997年春晚表演的小品剧本台词)
- 员工考勤表(通用版)
- 食品投标书121.doc【精品】
- 展览行业标准
评论
0/150
提交评论