La Web del Programador: Comunidad de Programadores
 
    Pregunta:  5621 - ROTAR TEXTO DE UN TEXTBOX
Autor:  Salvador Garufo
Deseo saber si alguien puede decirme como hago en Visual Basic para rotar un texto escrito en un textbox en una cantidad de grados puesto en otro textbox y que se imprima de esa forma.

  Respuesta:  José Ariel Limandri
Lo que tenes que hacer es rotar el texto pero ponerlo en un PictureBox (no en un TextBox) ya que el texto mas que texto se convierte en un grafico.
Crea un form con 1 PictureBox (Grande) y pegale esto

Option Explicit

Private Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal I As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long

Private Sub DrawRotatedText(ByVal target As Object, _
ByVal txt As String, _
ByVal X As Single, ByVal Y As Single, _
ByVal font_name As String, ByVal size As Long, _
ByVal weight As Long, ByVal escapement As Long, _
ByVal use_italic As Boolean, ByVal use_underline As Boolean, _
ByVal use_strikethrough As Boolean)

Const CLIP_LH_ANGLES = 16 ' Needed for tilted fonts.
Const PI = 3.14159625
Const PI_180 = PI / 180#

Dim newfont As Long
Dim oldfont As Long

newfont = CreateFont(size, 0, _
escapement, escapement, weight, _
use_italic, use_underline, _
use_strikethrough, 0, 0, _
CLIP_LH_ANGLES, 0, 0, font_name)

oldfont = SelectObject(target.hdc, newfont)

target.CurrentX = X
target.CurrentY = Y
target.Print txt

newfont = SelectObject(target.hdc, oldfont)

DeleteObject newfont
End Sub

Private Sub Form_Load()
Const PI = 3.14159265
Dim angle As Long
Width = Width - ScaleWidth + Picture1.Width
Height = Height - ScaleHeight + Picture1.Height
Picture1.Move 0, 0

angle = 100 * 180 / PI * Atn(Picture1.ScaleHeight / Picture1.ScaleWidth)

Picture1.AutoRedraw = True
Picture1.ForeColor = vbRed
DrawRotatedText Picture1, _
"Hola Mundo", _
1000, 500, _
"Times New Roman", 40, 700, _
angle, False, False, False

Picture1.Picture = Picture1.Image
End Sub