You are on page 1of 1

Dim partNum As String = partNumTextBox.Text Dim productName As String = productNameTextBox.Text Dim productPrice As String = priceTextBox.Text If partNum.

Length = 4 Then If partNum Like "[A-Z][A-Z]##" Then Dim outFile As IO.StreamWriter If IO.File.Exists("productInfo.txt") Then outFile = IO.File.AppendText("productInfo.txt") outFile.WriteLine(partNum & "," & productName & "," & productPrice) outFile.Close() partNumTextBox.Text = String.Empty productNameTextBox.Text = String.Empty priceTextBox.Text = String.Empty partNumTextBox.Focus() MessageBox.Show("Product info added succesfully.", "Premiere Products") Else Dim makeFile As DialogResult = MessageBox.Show("File does not exist. Do you wish to make it?", "ERROR", MessageBoxButtons.YesNo, MessageBoxIcon.Error) If makeFile = DialogResult.Yes Then outFile = IO.File.CreateText("productInfo.txt") outFile.Close() End If End If Else MessageBox.Show("Incorrect format. Please enter two letters followed by two numbers.", "ERROR") End If Else MessageBox.Show("Incorrect number of characters. Please enter only 4 characters.", "ERROR") End If

You might also like