Hanoun Fouad Hanoun Fouad - 10 months ago 48
Vb.net Question

Continue writing in a second line of richtextbox

I have a function that converts an int to its actual string value, and it works constantly while I type the number in a textbox and the function converts it into a richtextbox.

The problem is that when it converts, i want to continue writing in a new line in the richtextbox so it can be printed as two lines on a paper.

Here is what i tried to do.

TextBox2.Text = " " & NumberToText(AmountBox.Text)
If TextBox2.Text.Length() > 60 Then
End If

TextBox2 is the name of my richtextbox, and i chose 60 which is the average number of letters i want on my first line.

How can i let it continue converting the same number but on the second line ?

I want the output to be something like:

Four Hundreds Twenty Three Millions Four Hundreds Twenty -line1

Five Thousands Four Hundreds Twelve -line2

Any idea?


As Number to text as many return points you could use this intermediate function

Public Function NumberToTextSplitted(texto As String) As String
'Append this to what you are are already doing
Dim rtn as strin = NumberToText(texto)
Dim words As String() = rtn.Split(" ") 
Dim result As String = String.Empty

For Each word As String In words
    If line.Length + word.Length >= 59 Then
        result &= Environment.NewLine
    End If

    result &= " " & word

Return result

End Function