Showing an empty textbox using collections
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
Public Class CollectionsForm
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents TotalLabel As System.Windows.Forms.Label
Friend WithEvents AddButton As System.Windows.Forms.Button
Friend WithEvents TitleLabel As System.Windows.Forms.Label
Friend WithEvents JewelCasesTextbox As System.Windows.Forms.TextBox
Friend WithEvents JewelLabel As System.Windows.Forms.Label
Friend WithEvents MP3sTextbox As System.Windows.Forms.TextBox
Friend WithEvents MP3Label As System.Windows.Forms.Label
Friend WithEvents DVDsTextbox As System.Windows.Forms.TextBox
Friend WithEvents DVDLabel As System.Windows.Forms.Label
Friend WithEvents CDsTextbox As System.Windows.Forms.TextBox
Friend WithEvents CDLabel As System.Windows.Forms.Label
Private Sub InitializeComponent()
Me.TotalLabel = New System.Windows.Forms.Label
Me.AddButton = New System.Windows.Forms.Button
Me.TitleLabel = New System.Windows.Forms.Label
Me.JewelCasesTextbox = New System.Windows.Forms.TextBox
Me.JewelLabel = New System.Windows.Forms.Label
Me.MP3sTextbox = New System.Windows.Forms.TextBox
Me.MP3Label = New System.Windows.Forms.Label
Me.DVDsTextbox = New System.Windows.Forms.TextBox
Me.DVDLabel = New System.Windows.Forms.Label
Me.CDsTextbox = New System.Windows.Forms.TextBox
Me.CDLabel = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'TotalLabel
'
Me.TotalLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.TotalLabel.Location = New System.Drawing.Point(112, 312)
Me.TotalLabel.Name = "TotalLabel"
Me.TotalLabel.Size = New System.Drawing.Size(160, 23)
Me.TotalLabel.TabIndex = 21
'
'AddButton
'
Me.AddButton.Location = New System.Drawing.Point(144, 360)
Me.AddButton.Name = "AddButton"
Me.AddButton.Size = New System.Drawing.Size(75, 40)
Me.AddButton.TabIndex = 20
Me.AddButton.Text = "&Add"
'
'TitleLabel
'
Me.TitleLabel.AutoSize = True
Me.TitleLabel.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.TitleLabel.Location = New System.Drawing.Point(142, 35)
Me.TitleLabel.Name = "TitleLabel"
Me.TitleLabel.Size = New System.Drawing.Size(129, 25)
Me.TitleLabel.TabIndex = 19
Me.TitleLabel.Text = "Add Them Up"
'
'JewelCasesTextbox
'
Me.JewelCasesTextbox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.JewelCasesTextbox.Location = New System.Drawing.Point(222, 267)
Me.JewelCasesTextbox.Name = "JewelCasesTextbox"
Me.JewelCasesTextbox.TabIndex = 18
Me.JewelCasesTextbox.Text = ""
'
'JewelLabel
'
Me.JewelLabel.AutoSize = True
Me.JewelLabel.Location = New System.Drawing.Point(86, 267)
Me.JewelLabel.Name = "JewelLabel"
Me.JewelLabel.Size = New System.Drawing.Size(68, 16)
Me.JewelLabel.TabIndex = 17
Me.JewelLabel.Text = "&Jewel Cases"
'
'MP3sTextbox
'
Me.MP3sTextbox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.MP3sTextbox.Location = New System.Drawing.Point(222, 211)
Me.MP3sTextbox.Name = "MP3sTextbox"
Me.MP3sTextbox.TabIndex = 16
Me.MP3sTextbox.Text = ""
'
'MP3Label
'
Me.MP3Label.AutoSize = True
Me.MP3Label.Location = New System.Drawing.Point(86, 211)
Me.MP3Label.Name = "MP3Label"
Me.MP3Label.Size = New System.Drawing.Size(36, 16)
Me.MP3Label.TabIndex = 15
Me.MP3Label.Text = "&MP 3s"
'
'DVDsTextbox
'
Me.DVDsTextbox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.DVDsTextbox.Location = New System.Drawing.Point(222, 155)
Me.DVDsTextbox.Name = "DVDsTextbox"
Me.DVDsTextbox.TabIndex = 14
Me.DVDsTextbox.Text = ""
'
'DVDLabel
'
Me.DVDLabel.AutoSize = True
Me.DVDLabel.Location = New System.Drawing.Point(86, 155)
Me.DVDLabel.Name = "DVDLabel"
Me.DVDLabel.Size = New System.Drawing.Size(34, 16)
Me.DVDLabel.TabIndex = 13
Me.DVDLabel.Text = "&DVDs"
'
'CDsTextbox
'
Me.CDsTextbox.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.CDsTextbox.Location = New System.Drawing.Point(222, 99)
Me.CDsTextbox.Name = "CDsTextbox"
Me.CDsTextbox.TabIndex = 12
Me.CDsTextbox.Text = ""
'
'CDLabel
'
Me.CDLabel.AutoSize = True
Me.CDLabel.Location = New System.Drawing.Point(86, 99)
Me.CDLabel.Name = "CDLabel"
Me.CDLabel.Size = New System.Drawing.Size(26, 16)
Me.CDLabel.TabIndex = 11
Me.CDLabel.Text = "&CDs"
'
'CollectionsForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(408, 438)
Me.Controls.Add(Me.TotalLabel)
Me.Controls.Add(Me.AddButton)
Me.Controls.Add(Me.TitleLabel)
Me.Controls.Add(Me.JewelCasesTextbox)
Me.Controls.Add(Me.JewelLabel)
Me.Controls.Add(Me.MP3sTextbox)
Me.Controls.Add(Me.MP3Label)
Me.Controls.Add(Me.DVDsTextbox)
Me.Controls.Add(Me.DVDLabel)
Me.Controls.Add(Me.CDsTextbox)
Me.Controls.Add(Me.CDLabel)
Me.Name = "CollectionsForm"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Add Them Up"
Me.ResumeLayout(False)
End Sub
#End Region
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
-------
it has to do with the 3rd last line but im really not sure how to fix it
any help is appreciated :)