Displaying Text With Layout in a Text Box

  • Thread starter Montana DOJ Help Desk
  • Start date
M

Montana DOJ Help Desk

Word 2000

I've built a user form that contains a text box. I have the following code
to initialize a couple of values in the user form:

Private Sub UserForm_Initialize()

lblErrorMessage.Caption = ErrMsg
tbDataClip.Value = cbDataClip

End Sub

This basically works, but I've run into one small hitch that I can't seem to
solve. I would like the text box to display data like the following example
(Note that this is a test record, and not live data):

M*HR.MTHOT0000.MT0000000.*ABCTSTIUL9.

MONTANA HOT FILE RESPONSE FOR LOCATE OF:

NAM/TEST, RECORD.OCA/TESTABC.DOR/20040812.LAC/TESTTOM.DSP/EXTR





LOCATED RECORD NOTIFICATION



MKE/LOCATED MONTANA WANT

ORI/MT0000000

NAM/TEST, RECORD DOB/19700101

SEX/M RAC/W HGT/600 WGT/210 HAI/BRO

DOW/20040812 OCA/TESTABC OFF/2002 ARSON-RESIDENCE-ENDANGERED LIFE

MIS/TEST RECORD

LOCATED/20040812 MT025015Y TESTTOM EXTR

MIN/W320581 DTE/20040812







MRI 448220 IN: MTSF 6933 AT 12AUG2004 22:29:53 OUT: JLET00 537 AT
12AUG2004

22:29:53



Instead, the text box is displaying the data as a single unbroken row, with
the paragraph markers visible in the data string. I made sure that the Word
Wrap property of the text box is enabled. Is there some way to pass the
data to the text box so that the text box displays the data with the layout
intact?

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
 
H

Helmut Weber

Hi Tom,
how are the lines seperated?
They are displayed perfectly her and now,
whether I seperate them by ¶ or by a line feed.
 
M

Montana DOJ Help Desk

Originally, the data comes from a text-based system and is pasted into Word.
We do this because the text-based system has no automation abilities to
speak of, but in Word we have macros to help process the data. Once in
Word, the lines are separated by ¶, but the overall layout of the data
remains the same. However, when I pass the same data to the text box in my
form, it appears in the text box as follows:

Line 1¶Line 2¶Line 3¶Line 4¶

and so on. The ¶ symbol is literally visible in the text box (as shown in
the above example).

FYI: The form that displays the data in the text box is part of my error
checking routine. Th reason that I want to get the layout right is that the
form gives the user the choice of discarding the data, or keeping it despite
the error. It is just easier for the end user to recognize the data and
make the proper decision if the data is laid out in the familiar format.

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
Hi Tom,
how are the lines seperated?
They are displayed perfectly her and now,
whether I seperate them by ¶ or by a line feed.
 
H

Helmut Weber

Hi Tom,
I think you have to find out, what weird characters
your text-based system uses as paragraph or linefeed
markers. Can you analyze them?
Like selecting text from an ordinary character before
the paragraph mark until an ordinary character after
it, plus stepping through the string and looking for
the asc-values of the single characters. If you find
something odd, you are one step further. One method
I use, if all search and replacements of the weird
characters or combinations of them fail, is to
select the odd line feed or paragraph, cut it out
and selection.typetext text:=vbcr.
HTH
 
M

Montana DOJ Help Desk

Helmut,

Thanks again for the help. Our text-based system uses chr(10) for line
breaks. However, it turns out that the problem was with one of the
properties of the text box. I had looked through the properties a number of
times, and I turned on the Word Wrap property, but that wasn't the problem.

Finally, I went into the VB Editor and typed in the name of my text box, and
when I put in the period a list of properties came up, and I went through
all of them, looking up in Help any that sounded promising. I ended up
finding the Multiline property, which governs whether or not a control can
display multiple lines. So I checked that property on my text box, and it
was set to False. I set it to True, and now the text box displays the data
in the format that I wanted. And, the ¶ symbol is no longer visible in the
text box. I guess that only shows up when Multiline is set to False, as an
indicator that the actual data contains multiple lines. Therefore, when you
see the ¶ symbol in a text box, it's probably a good bet that the Multiline
property is set to False.

I must have checked the text box properties 8 or 10 times, and just never
saw the Multiline property--one of those "couldn't see the forest through
the trees" things I guess.

-- Tom

State of Montana
Department of Justice Help Desk

"Making the world a safer place."
 

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