practice7_6.frm

来自「深圳大学的vb上机与教学的课件」· FRM 代码 · 共 100 行

FRM
100
字号
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3600
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   7200
   LinkTopic       =   "Form1"
   ScaleHeight     =   3600
   ScaleWidth      =   7200
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command3 
      Caption         =   "查找"
      Height          =   495
      Left            =   3000
      TabIndex        =   4
      Top             =   2640
      Width           =   1215
   End
   Begin VB.TextBox Text2 
      Height          =   735
      Left            =   1560
      MultiLine       =   -1  'True
      ScrollBars      =   1  'Horizontal
      TabIndex        =   3
      Top             =   1560
      Width           =   5175
   End
   Begin VB.TextBox Text1 
      Height          =   855
      Left            =   1560
      MultiLine       =   -1  'True
      ScrollBars      =   1  'Horizontal
      TabIndex        =   2
      Top             =   360
      Width           =   5295
   End
   Begin VB.CommandButton Command2 
      Caption         =   "排序:"
      Height          =   495
      Left            =   240
      TabIndex        =   1
      Top             =   1680
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "生成数据:"
      Height          =   495
      Left            =   240
      TabIndex        =   0
      Top             =   480
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim A(1 To 20) As Integer
Private Sub Command1_Click()
   Randomize
   For I = 1 To 20
   A(I) = Int(Rnd * 50 + 1)
   Text1.Text = Text1.Text & Str(A(I)) & Space(3)
  Next I
End Sub

Private Sub Command2_Click()
 For I = 1 To 19
    For j = I + 1 To 20
      If A(I) < A(j) Then
        t = A(I)
        A(I) = A(j)
        A(j) = t
      End If
    Next j
  Next I
  Text2.Text = ""
  For I = 1 To 20
   Text2.Text = Text2.Text & Str(A(I)) & Space(3)
  Next I
End Sub

Private Sub Command3_Click()
   Number = Val(InputBox("请输入要查找的数"))
   k = 0
   For I = 1 To 20
      If Number = A(I) Then
         k = I
         Exit For
      End If
   Next I
   If k > 0 Then
      MsgBox "所找的数在第" & Str(k) & "个位置"
   Else
      MsgBox "没找到"
   End If
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?