Number of lines in a textbox

G

Guest

Hi!

Is there a way in a text box where i can say that user only can write
maby 25 lines ?

regards
alvin
 
A

Al Camp

Alvin,
Better to indicate how many characters a field can contain, rather than the number of
lines. The two don't always equate.
You can use the Control Tip Text property of the field to indicate to the user the
character limit of the field.
Or, just set up a label to the right of the field indicating that information
Label TextControl Label
MyField: [The Field] (50 Chars)
 
G

Guest

Yes i use a memo field
But how to set the memo field so the user only can write
maby 25 lines
regards


alvin
 
G

Guest

Hi

My problem is that i use a memo field
and this field i use on a asp page
but the field must not have more than mabye 25 lines

regards

alvin


Al Camp said:
Alvin,
Better to indicate how many characters a field can contain, rather than the number of
lines. The two don't always equate.
You can use the Control Tip Text property of the field to indicate to the user the
character limit of the field.
Or, just set up a label to the right of the field indicating that information
Label TextControl Label
MyField: [The Field] (50 Chars)

--
hth
Al Camp
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

alvin Kuiper said:
Hi!

Is there a way in a text box where i can say that user only can write
maby 25 lines ?

regards
alvin
 
D

Dirk Goldgar

alvin Kuiper said:
Hi!

Is there a way in a text box where i can say that user only can write
maby 25 lines ?

For example,

Dim strText As String
Dim nLines As Long

strText = Me!MyTextBox & vbNullString

' Trim of trailing CR/LF, if any.
If Right(strText, 2) = vbCrLf Then
strText = Left(strText, Len(strText) - 2)
End If

' Split on the CR/LF combination to see
' how many lines we have.
If Len(strText) = 0 Then
nLines = 0
Else
nLines = 1 + UBound(Split(strText, vbCrLf))
End If

If nLines > 25 Then
' not sure what you want to do here
End If
 
G

Guest

Thanks its working
is there a way where i can stop the user from
making a new line, in the code:


If nLines > 25 Then
' not sure what you want to do here
End If

regards
alvin
 
D

Dirk Goldgar

alvin Kuiper said:
Thanks its working
is there a way where i can stop the user from
making a new line, in the code:


If nLines > 25 Then

The easiest thing is to test this in the control's BeforeUpdate event,
and cancel the event if there are too many lines. That would leave it
up to the user to correct the problem. For example,

Private Sub txtMemo_BeforeUpdate(Cancel As Integer)

' ... code here to calculate nLines ...

If nLines > 25 Then
Cancel = True
MsgBox _
"That's too many lines. Please keep it to " & _
"25 lines or fewer.", _
vbExclamation,
"Too Many Lines"
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top