⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 插入元素.frm

📁 vb 程序基础设计与编程对初学者会有很大帮助
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "插入新元素"
   ClientHeight    =   3930
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4995
   LinkTopic       =   "Form1"
   ScaleHeight     =   3930
   ScaleWidth      =   4995
   StartUpPosition =   3  '窗口缺省
   Begin VB.PictureBox Picture1 
      Height          =   1815
      Left            =   2400
      ScaleHeight     =   1755
      ScaleWidth      =   2235
      TabIndex        =   4
      Top             =   1920
      Width           =   2295
   End
   Begin VB.CommandButton Command1 
      Caption         =   "插入元素"
      Height          =   495
      Left            =   1320
      TabIndex        =   2
      Top             =   960
      Width           =   1815
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   2040
      TabIndex        =   1
      Top             =   360
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "插入元素后的数组"
      Height          =   495
      Left            =   240
      TabIndex        =   3
      Top             =   2400
      Width           =   1455
   End
   Begin VB.Label Label1 
      Caption         =   "输入插入元素的值"
      Height          =   375
      Left            =   240
      TabIndex        =   0
      Top             =   360
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub ins(a() As Integer, x As Integer)
  Dim i%, k%
  For i = LBound(a) To UBound(a) - 2
    k = i
    For j = i + 1 To UBound(a) - 1
      If a(j) < a(k) Then k = j
    Next j
    t = a(i)
    a(i) = a(k)
    a(k) = t
  Next i
  For k = LBound(a) To UBound(a) - 1
    If x < a(k) Then Exit For
  Next k
  For i = UBound(a) - 1 To k Step -1
    a(i + 1) = a(i)
  Next i
  a(k) = x
End Sub

Private Sub Command1_Click()
  Dim b(1 To 16) As Integer, y As Integer
  y = Text1.Text
  For i = 1 To UBound(b()) - 1
    b(i) = Int(Rnd * 100)
  Next i
  ins b(), y
  For i = 1 To UBound(b())
    If i Mod 4 = 0 Then
      Picture1.Print b(i);
      Picture1.Print
    Else
      Picture1.Print b(i);
    End If
  Next i
   
      
    
End Sub

⌨️ 快捷键说明

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