?
Solved

Text box scrolling.

Posted on 2001-06-08
13
Medium Priority
?
285 Views
Last Modified: 2010-05-02
I have a textbox.. i would like to have multiline...
but not the wrapping effect.

how do you enable multiline.. without the wrap.

The issue is i want to display contents in the textbox...
but only the first few characters..unless the user makes the form bigger.. then the textbox will get biigger and they can see more..


thanks.

<no i dont want to put each line into a listbox.. i know this would give the same results.. but i dont want to go down that route as it is slow to build.>
0
Comment
Question by:TheAnswerMan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 5

Expert Comment

by:AndrewDev
ID: 6169478
This Text Box Enhancement might do a little of what you want
http://www.freevbcode.com/ShowCode.Asp?ID=2732

Regards
Andrew
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6169648
It sounds like what you want is property ScrollBar = 1 '- Horizontal'
0
 
LVL 28

Expert Comment

by:Ark
ID: 6169693
Private Type RECT
   Left As Long
   Top As Long
   Right As Long
   Bottom As Long
End Type
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_SETRECT = &HB3
Private Const EM_GETRECT = &HB2

Private Sub Form_Load()
  Dim rc As RECT
  SendMessage Text1.hWnd, EM_GETRECT, 0, rc
  rc.Right = rc.Right * 2 ' or more if you want, up to screen size
  SendMessage Text1.hWnd, EM_SETRECT, 0, rc
  Text1 = "Any long string you want"
End Sub

Cheers
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
gwgaw earned 200 total points
ID: 6170021
Ark has the right approach.

However you will have to set rc.left and rc.top to 0 and
rc.bottom to rc.bottom + 6.

This is because Windows will automatically set the left and
top to 1 more than you specify for the carret width and
height, which is usually 1 pixel wide and 2 pixels more
than the height of the text. Then Windows will recaculate
the bottom for the same reason.

Debug.print rc's values in the form load event after
getting rc and put a
"SendMessage Text1.hWnd, EM_GETRECT,  0, rc" in the
textbox change event and debug.print rc's values and
you'll see what i mean.
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177533
--adding the scrollbar does not stop the wrapping of the text.
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177616
OK.  This great.. it works.. I have to set the control width like this first..

Text1.Width = Me.ScaleWidth - Text1.Left - 120

''otherwise the control never resizes..


What is it that that  
"SendMessage Text1.hWnd, EM_SETRECT, 0, rc"

does?

Is there some internal rectangle in the textbox.. and  the text is actually drawn in that.?  and this sets it to be a wider number??
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177617
OK.  This great.. it works.. I have to set the control width like this first..

Text1.Width = Me.ScaleWidth - Text1.Left - 120

''otherwise the control never resizes..


What is it that that  
"SendMessage Text1.hWnd, EM_SETRECT, 0, rc"

does?

Is there some internal rectangle in the textbox.. and  the text is actually drawn in that.?  and this sets it to be a wider number??
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177727
OK.  This great.. it works.. I have to set the control width like this first..

Text1.Width = Me.ScaleWidth - Text1.Left - 120

''otherwise the control never resizes..


What is it that that  
"SendMessage Text1.hWnd, EM_SETRECT, 0, rc"

does?

Is there some internal rectangle in the textbox.. and  the text is actually drawn in that.?  and this sets it to be a wider number??
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6177748
Hmmm actually. I went back and add Both scroll bars..

and it got the desired effect.

<I had originally added Vertical bar.. not desired effect>

So this is the simplest..

but i like the concept of the Inner Rect modification..
so i dont have to have the scrollbar if I dont want it.

so will go with that as the answer.  Can I go 50-50 on the credit??
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6178106
If the inner box is what you liked, award the points there.  If you like both, you can go to the Customer Support section and post a zero-point question asking that the points be split between two experts...just reference the question ID (http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20132248) and the two experts who should receive the points.
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6181783
ahh effit.

i'll just give credit to both.

i'll post another questrion just for rspahitz
0
 
LVL 3

Author Comment

by:TheAnswerMan
ID: 6181791
ahh effit.

i'll just give credit to both.

i'll post another questrion just for rspahitz
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question