WordWrap Property Example

This example puts text into two Label controls and uses the WordWrap property to illustrate their different behavior. To try this example, paste the code into the Declarations section of a form that contains two Label controls, and then press F5 and click the form to toggle the WordWrap property setting.

Private Sub Form_Load ()
   Dim Author1, Author2, Quote1, Quote2   ' Declare variables.
   Label1.AutoSize = True   ' Set AutoSize.
   Label2.AutoSize = True
   Label1.WordWrap = True   ' Set WordWrap.
   Quote1 = "I couldn't wait for success, so I went on without it."
   Author1 = "  - Jonathan Winters"
   Quote2 = "Logic is a system whereby one may go wrong with confidence."
   Author2 = "  - Charles Kettering"
   Label1.Caption = Quote1 & Chr(10) & Author1
   Label2.Caption = Quote2 & Chr(10) & Author2
End Sub

Private Sub Form_Click ()
   Label1.Width = 1440   ' Set width to 1 inch in twips.
   Label2.Width = 1440
   Label1.WordWrap = Not Label1.WordWrap ' Toggle WordWrap property.
   Label2.WordWrap = Not Label2.WordWrap
End Sub