Solved

Vertically align text box

Posted on 2000-03-07
3
477 Views
Last Modified: 2010-05-02
I know when I program in Visual C++ I can vertically align the text in a text box... is it possible from VB?
0
Comment
Question by:taplin
[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
3 Comments
 
LVL 1

Accepted Solution

by:
ocpgmbh earned 100 total points
ID: 2592298
Directly from VB you can't use a vertical alignment, but you can use the DrawText API call.

For a complete example send an email to mshelp@microsoft.com with in the subject line "Q154517" without quotes.

Good work.

0
 
LVL 9

Expert Comment

by:Dalin
ID: 2592405
ocpgmbh is right,  VB Text box can't directly align vertically.

Draw text is a good alternative. However, If yiu have something over the text, it will be gone.

Another possible way is to do a little workaround. See if it works for you.

1. Set the textbox's multiline property to True.
2. Set alignment to Left or right or center,
3. In form load add the code
   Private Sub Form_Load()
     Dim lString As String
     Dim i As Integer
     If Len(Text1.Text) > 0 Then
     For i = 1 To Len(Text1.Text)
          lString = lString & Mid(Text1.Text, i, 1) & vbCrLf
       Next i
    Text1.Text = lString
   End If

 End Sub

In the Text's Change event, add:

Private Sub Text1_Change()
Dim lLastone As String
Dim lString As String
lString = Left(Text1.Text, Len(Text1.Text) - 1)
If Right(lString, 2) = vbCrLf Then Exit Sub
lLastone = Right(Text1.Text, 1)
lString = lString & vbCrLf & lLastOne
Text1.Text = lString
End Sub

Now your text has VBCRLF in it. When you need it somewhere, strip out the VBCRLF by:
ActualText = Replace(Text1.Text, vbCRLF, "")
0
 
LVL 2

Author Comment

by:taplin
ID: 2593311
Thank you both very much for your responses... I am going to accept the answer, as it works very well for what I need to do... I appreciate the information about anything above the text, though Dalin.

Your solution, Dalin, does not do what I wanted, though.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

734 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