Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21238

How to arrange numbering with line text properly

$
0
0
Hai experts..

I got 3 textboxes (txtInput, txtOutput, txtNumbers). After we put text in txtInput, it will be split based on "," character. Then the numbers will be produce in txtNumbers based on the line number in the txtOutput. Here is my code:

Code:

Private Sub Command1_Click()
Dim lines() As String, i As Integer
Dim x As String
lines() = Split(txtInput.Text, ",")

For i = 0 To UBound(lines)
 txtNumbers.Text = txtNumbers & (i + 1) & ": " & vbCrLf
 txtOutput.Text = txtOutput & lines(i) & vbCrLf
Next

It's ok if we put short sentence. The actual problem is when I want to put long sentence which produce "hanging text". The numbering not arrange properly with text. For example

when I put "aaaaa, bbbbb" it produce:
1. aaaaa
2. bbbbb

but if I put "aaaaaaaaaaaaaaaaaaaa, bbbbb":
1. aaaaaaaaaaaaaaa
2. aaaaa
bbbbb

the actual output I want is:
1. aaaaaaaaaaaaaaa
aaaaa
2. bbbbb

Hope someone can help.

Viewing all articles
Browse latest Browse all 21238

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>