Results 1 to 3 of 3

Thread: Rotating a label of command button on my VB form

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Posts
    316

    Rotating a label of command button on my VB form

    Is it possible to rotate a control on my VBform from left to right to vertical? For instance I want my command button or label to be rotated vertical rather than the standard horizontal.

    Thanks.
    Using VS 6 Enterprise w/ SP5 & Windows 2000 Professional

  2. #2
    New Member
    Join Date
    Nov 2003
    Location
    London UK
    Posts
    15

    Re: Rotating a label of command button on my VB form

    I don't think there is a way to rotate.

    But if you want the text to be vertical top to bottom then you could use:
    VB Code:
    1. Command1.Caption = "C" & vbCr & "o" & vbCr & "m" & vbCr & "m" & vbCr _ & "a" & vbCr & "n" & vbCr & "d" & vbCr & "1" & vbCr

    You could automate an input string into a for-next to add the CRs after each character.

    Its all down to appearance, as the vertical button will be bigger than the regular horizontal. Try it and see.

    Mike

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Rotating a label of command button on my VB form

    VB Code:
    1. Private Function ShowVertical(ByVal sMyString As String) As String
    2.     Dim sTheString As String
    3.     Dim i As Long
    4.        For i = 1 To Len(sMyString)
    5.            If i < Len(sMyString) Then
    6.                sTheString = sTheString + Mid$(sMyString, i, 1) & vbCrLf
    7.            Else
    8.                sTheString = sTheString + Mid$(sMyString, i, 1)
    9.            End If
    10.        Next
    11.        ShowVertical = sTheString
    12. End Function
    13.  
    14. Private Sub Form_Load()
    15. Label1.Caption = ShowVertical(Label1.Caption)
    16. 'and/or
    17. Command1.Caption = ShowVertical(Command1.Caption)
    18. End Sub
    Bare in the mind that the control needs to be stretched vertically enough so whatever the text is will be displayed in its entirety, or, you could programmatically adjust the control to accept the vertical text.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width