vb各类经典题目最新.doc_第1页
vb各类经典题目最新.doc_第2页
vb各类经典题目最新.doc_第3页
vb各类经典题目最新.doc_第4页
vb各类经典题目最新.doc_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

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

文档简介

09年12月26日编程题0113Private Sub Command1_Click()Text2.Text = Left(Text1.Text, 5) Text3.Text = Right(Text1.Text, 5) Text4.Text = Text2.Text & Text3.TextEnd Sub0114Private Sub Command1_Click() Dim num1 As Integer, num2 As Integer, sum As Integer, cha As Integer num1 = Val(Text1.Text) num2 = Val(Text2.Text) sum = num1 + num2 cha = num1 - num2 If Sqr(sum) = Fix(Sqr(sum) And Sqr(cha) = Fix(Sqr(cha) Then Text3.Text = yes Else Text3.Text = no End IfEnd Sub0115Private Sub Command1_Click() Dim N As Integer (注:此行代码由系统自动生成) Dim i As Integer N = Val(Text1.Text) Text2.Text = For i = 1 To N If Sqr(i) = Fix(Sqr(i) Then Text2.Text = Text2.Text & Str(i) & End If NextEnd Sub0116Private Sub Command1_Click()Dim s As String Text1.Text = Open K:ks1016830301zfcwj.txt For Input As #1 Line Input #1, s Text1.Text = s Text2.Text = Len(s) Close #1End Sub0117Private Sub Command1_Click()Dim i As Integer, a Randomize Text1.Text = For i = 1 To 20 a = Int(90 * Rnd + 10) Text1.Text = Text1.Text & a & If a = 65 And a D Then List2.AddItem N(i) End If Next iEnd Sub0214Private Sub Command1_Click()Text2.Text = zh(Text1.Text)End SubPrivate Function zh(s2 As String) As Double (注:此函数过程是系统自动生成的) Dim k As Integer, i As Integer, r As String, n As Integer k = Len(s2) zh = 0 For i = 1 To k r = Mid(s2, i, 1) If r Asc(maxchar) Then maxchar = s Next Label2.Caption = maxcharEnd Sub0105Private Sub Command1_Click() Dim sum As Integer, i As Integer, n As Integer Dim s As String n = Len(Text1.Text) sum = 0 For i = 1 To n s = Mid(Text1.Text, i, 1) sum = sum + Val(s) Next Text2.Text = Str(sum)End Sub0106Private Sub Command1_Click() Dim n As Integer n = Val(Text1.Text) If (n Mod 4 = 0 And n Mod 100 0) Or (n Mod 400 = 0) Then Text2.Text = 366 Else Text2.Text = 365 End IfEnd Sub0201Dim N(1 To 10) As String, i As Integer (注:此行代码由系统自动生成)Private Sub Command1_Click() List1.Clear Open K:ks1016830120yzfwj.txt For Input As #1 For i = 1 To 10 Input #1, N(i) List1.AddItem N(i) Next i Close #1End SubPrivate Sub Command2_Click() Dim t As String For i = 1 To 5 t = N(i) N(i) = N(11 - i) N(11 - i) = t Next i List2.Clear For i = 1 To 10 List2.AddItem N(i) Next iEnd Sub0202Private Sub Command1_Click() Text2.Text = zh(Text1.Text)End SubPrivate Function zh(s2 As String) As Double (注:此函数过程是系统自动生成的) Dim k As Integer, i As Integer, r As Integer k = Len(s2) zh = 0 For i = 1 To k r = Val(Mid(s2, i, 1) zh = zh + r * 8 (k - i) Next iEnd Function0203Dim Arr(10) As String (注:此行代码由系统自动生成)Private Sub Command1_Click() Dim i As Integer Open K:ks1016830225rywj.txt For Input As #1 For i = 1 To 10 Input #1, Arr(i) Next i Close #1End SubPrivate Sub Command2_Click() Dim i As Integer T1.Text = For i = 1 To 10 If Len(Arr(i) = 2 Then T1.Text = T1.Text & Arr(i) & End If NextEnd Sub0204Private Sub Command1_Click() Dim s As String Text1.Text = Open K:ks1016830301YY.txt For Input As #1 Do While Not EOF(1) Line Input #1, s Text1.Text = Text1.Text & s & vbCrLf Loop Close #1 End SubPrivate Sub Command2_Click() Dim i As Integer Dim n As Integer Dim count As Integer Dim s As String n = Len(Text1.Text) count = 0 For i = 1 To n s = UCase(Mid(Text1.Text, i, 1) If s Z Then count = count + 1 End If Next i Label1.Caption = 共 & count & 个非英文字母End Sub0205Private Sub Command1_Click() Dim i As Integer Text1.Text = For i = 1 To 10 Text1.Text = Text1.Text & sczf() NextEnd SubPrivate Sub Command2_Click() Text1.Text = UCase(Text1.Text)End SubPrivate Sub Command3_Click() Text1.Text = LCase(Text1.Text)End SubPrivate Function sczf() As String (注:此函数过程是系统自动生成的) Dim k As Integer Randomize k = Int(Rnd * 2 + 1) If k = 1 Then sczf = Chr(Int(Rnd * 26 + 65) Else sczf = Chr(Int(Rnd * 26 + 97) End IfEnd Function0206Private Sub Command1_Click() Dim n As Integer Dim i As Integer n = Val(Text1.Text) Open K:ks1016830311zfwj.txt For Output As #1For i = 1 To n Print #1, String(i, Format(i) Next i Close #1End Sub1Private Sub Command1_Click()Dim i As IntegerText1.Text = For i = 1 To 200 If (i Mod 3 = 0) And (i Mod 7 = 0) Then Text1.Text = Text1.Text & & i End If Next iEnd Sub2Private Sub Command1_Click() Dim n As Integer Dim i As Integer List1.Clear For n = 200 To 300 For i = 2 To n - 1 If n Mod i = 0 Then Exit For Next i If i n - 1 Then List1.AddItem n End If Next nEnd Sub3Private Sub command1_Click() Dim a As Integer, b As Integer, c As Integer Dim max As Integer, min As Integer a = Val(Text1.Text) b = Val(Text2.Text) c = Val(Text3.Text) max = IIf(a b, a, b) max = IIf(max c, max, c) min = IIf(a b, a, b) min = IIf(min c, min, c) Text4.Text = max Text5.Text = minEnd Sub4Private Sub Command1_Click() Dim n As Integer Dim i As Integer n = Val(Text1.Text) Open K:ks1016830311zfwj.txt For Output As #1 For i = 1 To n Print #1, String(i, *) Next i Close #1End Sub5Private Sub Command1_Click()Dim i As Integer List1.Clear For i = 1 To 10 List1.AddItem Int(90 * Rnd + 10) Next iEnd SubPrivate Sub Command2_Click() Dim i As Integer Dim n As Integer n = List1.ListCount For i = n - 1 To 0 Step -1 If Val(List1.List(i) Mod 2 0 Then List2.AddItem List1.List(i), 0 List1.RemoveItem i End If Next iEnd SubPrivate Sub Command3_Click() List1.Clear List2.ClearEnd Sub6Dim a(1 To 10) As String, i As Integer (注:此行是系统自动生成的代码)Private Sub Command1_Click() Text1.Text = Open K:ks1016830120zfwj.txt For Input As #1 For i = 1 To 10 Input #1, a(i) Text1.Text = Text1.Text & a(i) & Next i Close #1End SubPrivate Sub Command2_Click() Dim t As String For i = 1 To 5 t = a(i) a(i) = a(11 - i) a(11 - i) = t Next i Text2.Text = For i = 1 To 10 Text2.Text = Text2.Text & a(i) & Next iEnd Sub7Private Sub Command1_Click() Dim s As String Call GetChar(s) Text1.Text = s Select Case s Case a To z, A To Z Label1.Caption = 是字母字符 Case 0 To 9 Label1.Caption = 是数字字符 Case Else Label1.Caption = 是其它字符 End SelectEnd SubSub GetChar(ByRef char) (注:此通用过程是系统自动生成的) Randomize char = Chr(Int(Rnd * 256)End Sub9Dim a(1 To 10) As Integer (注:此行代码由系统自动生成)Private Sub Command1_Click() Dim i As Integer Open K:ks1016830225yssj.txt For Input As #1 For i = 1 To 10 Input #1, a(i) Next i Close #1End SubPrivate Sub Command2_Click() Dim i As Integer Text1.Text = For i = 1 To 10 If a(i) Mod 3 = 2 Then Text1.Text = Text1.Text & a(i) & End If Next iEnd Sub10Private Sub Command1_Click() Dim a As Integer, b As Integer Randomize a = Val(Text1.Text) b = Val(Text2.Text) Label1.Caption = Int(b - a + 1) * Rnd + a) Label2.Caption = Int(b - a + 1) * Rnd + a) Label3.Caption = Int(b - a + 1) * Rnd + a)End Sub11Private Sub Command1_Click() Dim s As String Text1.Text = Open K:ks1016830301YY.txt For Input As #1 Do While Not EOF(1) Line Input #1, s Text1.Text = Text1.Text & s & vbCrLf Loop Close #1End SubPrivate Sub Command2_Click() Dim i As Integer Dim n As Integer Dim count As Integer Dim s As String n = Len(Text1.Text) For i = 1 To n s = UCase(Mid(Text1.Text, i, 1) If s = A And s x(p) Then p = j Next j t = x(i) x(i) = x(p) x(p) = t Next i Text2.Text = For i = 1 To 15 Text2.Text = Text2.Text & & x(i) Next iEnd Sub18Dim Arr(15) As Integer (注:此行代码由系统自动生成)Private Sub Command1_Click() Dim i As Integer Open K:ks1016830303Jsdata.txt Fo

温馨提示

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

评论

0/150

提交评论