Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim arry() As String
arry = Split(TextBox1.Text, vbCrLf) '将每行内容放到数组中,
Dim i, j As Integer
TextBox1.Text = ""
For i = 0 To UBound(arry)
If Len(Trim(arry(i))) > 0 Then '
j = j + 1
TextBox1.Text = TextBox1.Text & CStr(i + 1) & ". " & arry(i) & vbCrLf '输出的每一行内容
End If
Next
MsgBox(TextBox1.Text)
End Sub
End Class
把上述代码放入textbox1中,输出结果如下: