Option Base 1
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETLINE = &HC4
Private Const EM_GETLINECOUNT = &HBA
Private Sub Command1_Click()
Text1.Text = Clipboard.GetText(1)
Dim lngLineIndex As Long
Dim lngLineCount As Long
lngLineCount = SendMessage(Text1.hwnd, EM_GETLINECOUNT, 0&, 0&)
Text2.Text = lngLineCount
Dim st1(255) As String
Dim i, j As Integer
Dim temp As String
For i = 1 To lngLineCount
st1(i) = Split(Text1.Text, ",", -1)
Next i
For i = 1 To lngLineCount - 1
For j = i + 1 To lngLineCount
If Len(st1(i)) > Len(st1(j)) Then
temp = st1(i)
st1(i) = st1(j)
st1(j) = temp
End If
Next j
Next i
For i = 1 To lngLineCount
Text1.Text = Text1.Text & st1(i) & vbCrLf
Next i
End Sub