📄 frmsortmain.frm
字号:
VERSION 5.00
Begin VB.Form frmSortMain
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 6810
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 6810
StartUpPosition = 3 'Windows Default
Begin VB.Frame frmSortTime
Caption = "Time Taken"
Height = 615
Left = 3240
TabIndex = 3
Top = 720
Width = 3135
Begin VB.Label lblTime
BackStyle = 0 'Transparent
Caption = "0 Sec"
Height = 255
Left = 120
TabIndex = 4
Top = 240
Width = 2895
End
End
Begin VB.ListBox List2
Height = 2985
Left = 1680
TabIndex = 2
Top = 120
Width = 1455
End
Begin VB.ListBox List1
Height = 2985
Left = 120
TabIndex = 1
Top = 120
Width = 1455
End
Begin VB.CommandButton cmdSort
Caption = "Sort List"
Height = 495
Left = 3240
TabIndex = 0
Top = 120
Width = 1215
End
End
Attribute VB_Name = "frmSortMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim words(0 To 100) As String
Dim counter1 As Integer
Dim counter2 As Integer
Dim ordered As Boolean
Dim time As Long
Dim filenum As Integer
Dim importcounter As Integer
Private Sub cmdSort_Click()
time = Timer
ordered = False
For counter1 = 100 To 2 Step -1
If ordered = True Then Exit For
ordered = True
For counter2 = 1 To counter1 - 1
If words(counter2) > words(counter2 + 1) Then
words(0) = words(counter2)
words(counter2) = words(counter2 + 1)
words(counter2 + 1) = words(0)
ordered = False
End If
Next counter2
Next counter1
lblTime = Timer - time & " SEC"
List2.Clear
Open App.Path & "\sorted.txt" For Output As #filenum
For counter1 = 1 To 100
List2.AddItem words(counter1)
Write #filenum, words(counter1)
Next counter1
Close #filenum
End Sub
Private Sub Form_Load()
filenum = FreeFile
Open App.Path & "\orig.txt" For Input As #filenum
For importcounter = 1 To 100
Input #filenum, words(importcounter)
List1.AddItem words(importcounter)
Next importcounter
Close #filenum
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -