Hey guys Just learning about List Boxes, I have a quick Question Im Creating the Program where I have 3 text boxes and when I hit the add button it adds them to the list box off to the right if they already Exist in the list box then it will bring up a message box saying that it already exists.
I have another button labled Replace button and its suppose to update or replace the string or line if changes are needed to be updated or replaced. How can I creat it to Replace or update the Data in the String or Line?
Here is my Code:
Public Class Form1 Dim ID As Integer Dim AName As String Dim ABalance As Double Private Sub AddButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddButton.Click ID = AccountIDTextBox.Text AName = AccountNameTextBox.Text ABalance = BalanceTextBox.Text If AccountsListBox.Items.Contains(ID & ", " & AName & ", $" & ABalance) = True Then 'Checks to see if the line or String Exists MessageBox.Show("That Account already Exists!") 'If it does Exist or is already created Else AccountsListBox.Items.Add(ID & ", " & AName & ", $" & ABalance) 'If it it dosent exist it inserts or adds the line to the listbox End If End Sub Private Sub ReplaceButton_Click(sender As System.Object, e As System.EventArgs) Handles ReplaceButton.Click If AccountsListBox.Items.Contains(ID & ", " & AName & ", $" & ABalance) = True Then 'If the Line Does Exist replace or update the String or line Else MessageBox.Show("You cant replace that account because the Account dosent Exist!") 'If line does not Exist does not update or add End If End Sub End Class