Hi Paul,
I want to stop the user, if s/he tries to start a 4th line. Not tell her/him
after the 4th and maybe more lines are entered.
The answer from Herfried is in my eyes very correct.
Only what is a line, a line is a string in a textbox ended with the Enter
key (vbcrlf).
When you means visible lines in a textbox, than is that something else, you
can than thinking on measure the textlenght, but what you cannot measure as
far as I know is the part where the textbox gives a wordwrap.
The instruction would else be very simple something as
\\\
Private Sub TextBox1_TextChanged(ByVal sender _
As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
If (Me.TextBox1.Width * 3) < CInt(Graphics.FromHwnd(Me.Handle).MeasureString
_
(Me.TextBox1.Text, Me.TextBox1.Font).Width) - 1 then
' Do some action to tell the user that there are more than 3 lines
end if
end sub
///
But this fails because the fact there is a not measured LF (or CR I do not
know) in it.
And I did not see it either, because the textbox1.text gives a string back
without that.
Cor