As for the form, the user enters the data, but if they need to add additional items (i.e. more people, property vehicles), I need the data to save to an excel file, but clear the form. I have been able to get the textboxes and rich textboxes to clear, but I am unsure how to have combo boxes clear out (go blank). Here is a snippet of what I've written for the text and rich textboxes. Intellisense won't let me select selectindex and I'm currently stuck.

For Each Me.cControl In Person.Controls
If (TypeOf cControl Is TextBox) Then
cControl.Text = ""
End If
If (TypeOf cControl Is RichTextBox) Then
cControl.Text = ""
End If
Next cControl

Recommended Answers

Try cmbMyCombo.Items.Clear()

Jump to Post

All 3 Replies

Try cmbMyCombo.Items.Clear()

Try this :

Private Sub ClearCombo(ByVal MyCombo As ComboBox)
End Sub

For Each ccontrol In Me.Controls
    If TypeOf ccontrol Is ComboBox Then
        ccontrol.Text = ""
    End If
Next ccontrol

Sorry. Misunderstood. You could set

cmbMyCombo.SelectedIndex = -1

and that will unselect all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.