tdpowell23

tdpowell23

  • NA
  • 38
  • 0

Showing an empty textbox using collections

May 13 2005 4:05 PM
hi i got a little program working and i want the program to show in a messagebox that there is an empty textbox when you click a button. Unfortunately i can not get it working. Here is the code Private textboxcollection As New Collection Private Sub CollectionsForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load textboxcollection.Add(CDsTextbox) textboxcollection.Add(DVDsTextbox) textboxcollection.Add(MP3sTextbox) textboxcollection.Add(JewelCasesTextbox) End Sub Private Sub totallabelclear(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CDsTextbox.TextChanged, _ DVDsTextbox.TextChanged, MP3sTextbox.TextChanged, JewelCasesTextbox.TextChanged TotalLabel.Text = String.Empty End Sub Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click Dim objtextboxes As New TextBox Dim dectotal As Decimal, decsum As Decimal Try For Each objtextboxes In textboxcollection dectotal = objtextboxes.Text decsum += dectotal TotalLabel.Text = decsum Next objtextboxes Catch MessageBox.Show("Each textbox must contain a number" & ControlChars.NewLine & ControlChars.NewLine & "Check the value of " & objtextboxes.Text) End Try End Sub End Class ------- it has to do with the 3rd last line but im really not sure how to fix it any help is appreciated :)

Answers (5)