Part | Description | |
object | Required. A valid object. |
Dim EntryCount As Single
Private Sub CommandButton1_Click()
EntryCount = EntryCount + 1
ListBox1.AddItem (EntryCount & " - Selection")
End Sub
Private Sub CommandButton2_Click()
ListBox1.SetFocus
'Ensure ListBox contains list items
If ListBox1.ListCount >= 1 Then
'If no selection, choose last list item.
If ListBox1.ListIndex = -1 Then
ListBox1.ListIndex = ListBox1.ListCount - 1
End If
ListBox1.RemoveItem (ListBox1.ListIndex)
End If
End Sub
Private Sub UserForm_Initialize()
EntryCount = 0
CommandButton1.Caption = "Add Item"
CommandButton2.Caption = "Remove Item"
End Sub
'Type SHIFT+ENTER to start a new line in the text box.
Private Sub CommandButton1_Click()
'Must first give TextBox1 the focus to get line count
TextBox1.SetFocus
Label1.Caption = "LineCount = " & TextBox1.LineCount
Label2.Caption = "TextLength = " & TextBox1.TextLength
End Sub
Private Sub UserForm_Initialize()
CommandButton1.WordWrap = True
CommandButton1.AutoSize = True
CommandButton1.Caption = "Get Counts"
Label1.Caption = "LineCount = "
Label2.Caption = "TextLength = "
TextBox1.MultiLine = True
TextBox1.WordWrap = True
TextBox1.Text = "Enter your text here."
End Sub