|
Sub 倒序排列()
Dim oText As String, a() As String, i As Long, j As Long, temp As String
oText = IIf(Selection.Type = wdSelectionIP, ActiveDocument.Content.Text, Selection.Text)
oText = Left(oText, Len(oText) - 1)
a() = Split(oText, Chr(13))
For i = 0 To UBound(a) - 1
For j = i + 1 To UBound(a)
If Len(a(i)) < Len(a(j)) Then
temp = a(j)
a(j) = a(i)
a(i) = temp
End If
Next j
Next i
Documents.Add.Content.Text = Join(a, Chr(13))
End Sub
Sub 正序排列()
Dim oText As String, a() As String, i As Long, j As Long, temp As String
oText = IIf(Selection.Type = wdSelectionIP, ActiveDocument.Content.Text, Selection.Text)
oText = Left(oText, Len(oText) - 1)
a() = Split(oText, Chr(13))
For i = 0 To UBound(a) - 1
For j = i + 1 To UBound(a)
If Len(a(i)) > Len(a(j)) Then
temp = a(j)
a(j) = a(i)
a(i) = temp
End If
Next j
Next i
Documents.Add.Content.Text = Join(a, Chr(13))
End Sub |
|