Determine whether test will fit in textbox

D

Dale Fye

I have a continuous form that I am using to display a bunch of text to a
user, so they can easily scroll through the records. I'm looking for a
function which I can run that will tell me whether the text in the textbox is
completely visible or not.

Ideally, I'd like to use this function in a conditional formatting criteria
so that if the text exceeds what is visible in the textbox, I can color code
the textbox.

Any ideas?
 
M

Maurice

Dale,

I think the first thing you should do is test yourself how many characters
do fit in your textbox while staying visible to read. When you've determined
that you can use this in your function.

Example: let's say your textbox can store up to 50 characters which will be
directly visible to the user. You have your controlpoint set.

function DoesItFit (strText as string) as boolean
if len(strtext) <50 then
DoesItFit=true
else
DoeItTit=false
end if

end function

Now you can use the boolean value to do your testing with on your form.

hth
 
D

Dale Fye

Maurice,

Already thought about that. It would be a starting point for a single line
text box, but the one I'm interested in has multiple (5) lines currently
displayable. And the text includes CRLF characters etc.

So what I really need is the ability to count the number of rows that will
be needed to display the text.

Thanks for the suggestion.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
J

John W. Vinson

So what I really need is the ability to count the number of rows that will
be needed to display the text.

Very, Very difficult, if you allow word wrap and variable pitch font. The text
string "MMMMMMMMMMMMMMMMMMMM" takes up a lot more room than the equal length
"llllllllllllllllllll", and different fonts will have different physical
lengths. (I see that the difference fooled Agent's Word Wrap feature in this
very message!)
 
D

Dale Fye

I know it's hard, John.

I was just hoping someone had figured it out, or at least come up with a
reasonable assessment based on font type, size and height/width of the
textbox.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 
D

Dale Fye

John,

See my post (Calling function in conditional formatting expression) dated
today to continue this thread.

--
Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.
 

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