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

📄 单词排序.frm

📁 vb单词排序实现算法
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3675
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5415
   LinkTopic       =   "Form1"
   ScaleHeight     =   3675
   ScaleWidth      =   5415
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "排        序"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2535
      Left            =   4800
      TabIndex        =   14
      Top             =   720
      Width           =   375
   End
   Begin VB.Frame Frame2 
      Height          =   2775
      Left            =   2520
      TabIndex        =   8
      Top             =   600
      Width           =   2055
      Begin VB.TextBox Text10 
         Height          =   375
         Left            =   120
         TabIndex        =   13
         Top             =   240
         Width           =   1695
      End
      Begin VB.TextBox Text9 
         Height          =   375
         Left            =   120
         TabIndex        =   12
         Top             =   720
         Width           =   1695
      End
      Begin VB.TextBox Text8 
         Height          =   375
         Left            =   120
         TabIndex        =   11
         Top             =   1200
         Width           =   1695
      End
      Begin VB.TextBox Text7 
         Height          =   375
         Left            =   120
         TabIndex        =   10
         Top             =   1680
         Width           =   1695
      End
      Begin VB.TextBox Text6 
         Height          =   375
         Left            =   120
         TabIndex        =   9
         Top             =   2160
         Width           =   1695
      End
   End
   Begin VB.Frame Frame1 
      Height          =   2775
      Left            =   120
      TabIndex        =   1
      Top             =   600
      Width           =   2055
      Begin VB.TextBox Text5 
         Height          =   375
         Left            =   120
         TabIndex        =   6
         Top             =   2160
         Width           =   1695
      End
      Begin VB.TextBox Text4 
         Height          =   375
         Left            =   120
         TabIndex        =   5
         Top             =   1680
         Width           =   1695
      End
      Begin VB.TextBox Text3 
         Height          =   375
         Left            =   120
         TabIndex        =   4
         Top             =   1200
         Width           =   1695
      End
      Begin VB.TextBox Text2 
         Height          =   375
         Left            =   120
         TabIndex        =   3
         Top             =   720
         Width           =   1695
      End
      Begin VB.TextBox Text1 
         Height          =   375
         Left            =   120
         TabIndex        =   2
         Top             =   240
         Width           =   1695
      End
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "排序结果输出:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   2640
      TabIndex        =   7
      Top             =   240
      Width           =   1680
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "请输入英文单词:"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   240
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   1920
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim a(5) As String
Dim i, j, pf As Integer
Dim string1 As String
Dim t As Boolean
t = "a" > ""
a(1) = Text1.Text
a(2) = Text2.Text
a(3) = Text3.Text
a(4) = Text4.Text
a(5) = Text5.Text
For i = 2 To 5
  a(0) = a(i)
  j = i - 1
  pf = 0
  Call paixu(a(0), a(j), pf)
  Do While pf = 1
     a(j + 1) = a(j)
     j = j - 1
     Call paixu(a(0), a(j), pf)
  Loop
  a(j + 1) = a(0)
Next i
Text10.Text = a(1)
Text9.Text = a(2)
Text8.Text = a(3)
Text7.Text = a(4)
Text6.Text = a(5)

End Sub
Public Sub paixu(word1 As String, word2 As String, pf As Integer)
  Dim m As Integer
  Dim lengthwd  As Integer
  If Len(word1) > Len(word2) Then
    lengthwd = Len(word1)
  Else
    lengthwd = Len(word2)
  End If
  pf = 0
  For m = 1 To lengthwd
    If UCase$(Mid$(word1, m, 1)) < UCase$(Mid(word2, m, 1)) Then
       pf = 1
       Exit For
    Else
      If UCase$(Mid$(word1, m, 1)) > UCase$(Mid(word2, m, 1)) Then
        pf = 0
        Exit For
      End If
    End If
  Next m
End Sub


⌨️ 快捷键说明

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