G
G33kman
Guest
OK Im new to Visual Basic (other than some tinkering around) what Im trying to do is create a lead log so when we have a customer call we can enter this information into the program and have it save that information to a file so we can look back at that information at a later time.
Im having trouble figuring out how to take the information on the form and save it to an XML File (I figured this part out) and than if the file exists already add the new information to the file.
Heres pictures of the two forms that I have.
The First (not start up window that shows up)
The Second (start up window) form that shows up
Hopefully you can get a good grasp of what Im trying to achieve here.
Heres the code that I have so far ( I know its still gonna need some work) :/
The code for the first (smaller) form
Public Class startWindow
Private strFileName As String
WHAT HAPPENS WHEN THE NEW BUTTON IS CLICKED
Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
Me.Close()
mainWindow.Show()
End Sub
WHAT HAPPENS WHEN THE OPEN BUTTON IS CLICKED
Private Sub btnOpen_Click(sender As Object, e As EventArgs) Handles btnOpen.Click
Set ofdStartWindow Properties
With ofdStartWindow
.Filter = "Reichel Log (*.rei)|*.rei|All Files (*.*)|*.*"
.FilterIndex = 1
.Title = "Open Reichel Insulation - Lead Log File"
.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\nf"
End With
Show the ofdStartWindow dialog window
If ofdStartWindow.ShowDialog = Windows.Forms.DialogResult.OK Then
Try
Save the file path and name
strFileName = ofdStartWindow.FileName
txtLogLocation.Text = strFileName
Catch ex As Exception
MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
ENABLE THE ACCEPT BUTTON ONLY IF THE TEXT BOX HAS A FILE LISTED
Private Sub txtLogLocation_TextChanged(sender As Object, e As EventArgs) Handles txtLogLocation.TextChanged
If txtLogLocation.Text = "" Then
btnContinue.Enabled = False
Else
btnContinue.Enabled = True
End If
End Sub
WHAT HAPPENS WHEN THE ACCEPT BUTTON IS CLICKED
Private Sub btnContinue_Click(sender As Object, e As EventArgs) Handles btnContinue.Click
Close()
mainWindow.Show()
End Sub
WHAT HAPPENS WHEN THE CANCEL BUTTON IS CLICKED
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
If txtLogLocation.Text = "" Then
mainWindow.Close()
Else
Dim ask As MsgBoxResult
ask = MessageBox.Show("Quit Without Saving?", My.Application.Info.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If ask = MsgBoxResult.Yes Then
mainWindow.Close()
End If
End If
End Sub
End Class
The code for the Second (Bigger) form
Imports System.IO
Public Class mainWindow
DECLARE VARIABLES
Dim strFileName As String
MAIN WINDOW LOAD EVENT
Private Sub mainWindow_Load(sender As Object, e As EventArgs) Handles Me.Load
startWindow.ShowDialog()
End Sub
SALES REP COMBO BOX
Private Sub cbxRep_Enter(sender As Object, e As EventArgs) Handles cbxRep.Enter
statusLabel.Text = "Select the Sales Rep that this Lead will be going to."
End Sub
JOB TYPE COMBO BOX
Private Sub cbxJobType_Enter(sender As Object, e As EventArgs) Handles cbxJobType.Enter
statusLabel.Text = "Select the Type of Insulation Job that the Customer would like a Quote for."
End Sub
DISLPLAY THE statusLabel FOR cbxSource TEXT INFORMATION
Private Sub cbxSource_Click(sender As Object, e As EventArgs) Handles cbxSource.Click
statusLabel.Text = "Select where the customer heard about us From. Select other to input a custom place."
End Sub
ENABLE txtSource TEXT BOX IF OTHER IS SELECTED IN THE COMBO BOX
Private Sub cbxSource_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxSource.SelectedValueChanged
If cbxSource.SelectedItem = "Other" Then
txtSource.Enabled = True
Else
txtSource.Enabled = False
End If
End Sub
WHAT HAPPENS WHEN THE txtSource TEXT BOX IS CLICKED
Private Sub txtSource_Enter(sender As Object, e As EventArgs) Handles txtSource.Enter
txtSource.ForeColor = Color.Black
If txtSource.Text = "Other" Then
txtSource.Text = ""
Else
txtSource.Text = txtSource.Text
End If
statusLabel.Text = "Fill out the place where the customer heard about us"
End Sub
WHAT HAPPENS WHEN THE txtSource TEXT BOX IS LEFT EMPTY
Private Sub txtSource_Leave(sender As Object, e As EventArgs) Handles txtSource.Leave
If txtSource.Text Is "" Then
txtSource.Text = "Other"
txtSource.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE FirstName TEXT BOX IS CLICKED
Private Sub txtFirstName_Enter(sender As Object, e As EventArgs) Handles txtFirstName.Enter
txtFirstName.ForeColor = Color.Black
If txtFirstName.Text = "John" Then
txtFirstName.Text = ""
Else
txtFirstName.Text = txtFirstName.Text
End If
statusLabel.Text = "Fill in the Customers First Name"
End Sub
WHAT HAPPENS WHEN THE txtFirstName TEXT BOX IS LEFT EMPTY
Private Sub txtFirstName_Leave(sender As Object, e As EventArgs) Handles txtFirstName.Leave
If txtFirstName.Text Is "" Then
txtFirstName.Text = "John"
txtFirstName.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtLastName TEXT BOX IS CLICKED
Private Sub txtLastName_Enter(sender As Object, e As EventArgs) Handles txtLastName.Enter
txtLastName.ForeColor = Color.Black
If txtLastName.Text = "Doe" Then
txtLastName.Text = ""
Else
txtLastName.Text = txtLastName.Text
End If
statusLabel.Text = "Fill in the Customers Last Name"
End Sub
WHAT HAPPENS WHEN THE txtLastName TEXT BOX IS LEFT EMPTY
Private Sub txtLastName_Leave(sender As Object, e As EventArgs) Handles txtLastName.Leave
If txtLastName.Text Is "" Then
txtLastName.Text = "Doe"
txtLastName.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtAddress1 TEXT BOX IS CLICKED
Private Sub txtAddress1_Enter(sender As Object, e As EventArgs) Handles txtAddress1.Enter
txtAddress1.ForeColor = Color.Black
If txtAddress1.Text = "54040 Loren Dr." Then
txtAddress1.Text = ""
Else
txtAddress1.Text = txtAddress1.Text
End If
statusLabel.Text = "Fill in the Customers Address"
End Sub
WHAT HAPPENS WHEN THE txtAddress1 TEXT BOX IS LEFT EMPTY
Private Sub txtAddress1_Leave(sender As Object, e As EventArgs) Handles txtAddress1.Leave
If txtAddress1.Text Is "" Then
txtAddress1.Text = "54040 Loren Dr."
txtAddress1.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtAddress2 TEXT BOX IS CLICKED
Private Sub txtAddress2_Enter(sender As Object, e As EventArgs) Handles txtAddress2.Enter
txtAddress2.ForeColor = Color.Black
If txtAddress2.Text = "Mankato" Then
txtAddress2.Text = ""
Else
txtAddress2.Text = txtAddress2.Text
End If
statusLabel.Text = "Fill in the Customers City"
End Sub
WHAT HAPPENS WHEN THE txtAddress2 TEXT BOX IS LEFT EMPTY
Private Sub txtAddress2_Leave(sender As Object, e As EventArgs) Handles txtAddress2.Leave
If txtAddress2.Text Is "" Then
txtAddress2.Text = "Mankato"
txtAddress2.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtZipCode TEXT BOX IS CLICKED
Private Sub txtZipCode_Enter(sender As Object, e As EventArgs) Handles txtZipCode.Enter
txtZipCode.ForeColor = Color.Black
If txtZipCode.Text = "56001" Then
txtZipCode.Text = ""
Else
txtZipCode.Text = txtZipCode.Text
End If
statusLabel.Text = "Fill in the Customers Zip Code"
End Sub
WHAT HAPPENS WHEN THE txtZipCode TEXT BOX IS LEFT EMPTY
Private Sub txtZipCode_Leave(sender As Object, e As EventArgs) Handles txtZipCode.Leave
If txtZipCode.Text Is "" Then
txtZipCode.Text = "56001"
txtZipCode.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtBusinessName TEXT BOX IS CLICKED
Private Sub txtBusinessName_Enter(sender As Object, e As EventArgs) Handles txtBusinessName.Enter
txtBusinessName.ForeColor = Color.Black
If txtBusinessName.Text = "Reichel Insulation" Then
txtBusinessName.Text = ""
Else
txtBusinessName.Text = txtBusinessName.Text
End If
statusLabel.Text = "Fill in the Business Name"
End Sub
WHAT HAPPENS WHEN THE txtBusinessName TEXT BOX IS LEFT EMPTY
Private Sub txtBusinessName_Leave(sender As Object, e As EventArgs) Handles txtBusinessName.Leave
If txtBusinessName.Text Is "" Then
txtBusinessName.Text = "Reichel Insulation"
txtBusinessName.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtEmail TEXT BOX IS CLICKED
Private Sub txtEmail_Enter(sender As Object, e As EventArgs) Handles txtEmail.Enter
txtEmail.ForeColor = Color.Black
If txtEmail.Text = "someone@somewhere.com" Then
txtEmail.Text = ""
Else
txtEmail.Text = txtEmail.Text
End If
statusLabel.Text = "Fill in the Customers Email Address"
End Sub
WHAT HAPPENS WHEN THE txtEmail TEXT BOX IS LEFT EMPTY
Private Sub txtEmail_Leave(sender As Object, e As EventArgs) Handles txtEmail.Leave
If txtEmail.Text Is "" Then
txtEmail.Text = "someone@somewhere.com"
txtEmail.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP1AreaCode TEXT BOX IS CLICKED
Private Sub txtP1AreaCode_Enter(sender As Object, e As EventArgs) Handles txtP1AreaCode.Enter
txtP1AreaCode.ForeColor = Color.Black
If txtP1AreaCode.Text = "507" Then
txtP1AreaCode.Text = ""
Else
txtP1AreaCode.Text = txtP1AreaCode.Text
End If
statusLabel.Text = "Fill in the Area Code for the Customers Main Phone Number"
End Sub
Private Sub txtP1AreaCode_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtP1AreaCode.KeyPress
If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) Then
e.Handled = True
End If
End Sub
WHAT HAPPENS WHEN THE txtP1AreaCode TEXT BOX IS LEFT EMPTY
Private Sub txtP1AreaCode_Leave(sender As Object, e As EventArgs) Handles txtP1AreaCode.Leave
If txtP1AreaCode.Text Is "" Then
txtP1AreaCode.Text = "507"
txtP1AreaCode.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP1First TEXT BOX IS CLICKED
Private Sub txtP1First_Enter(sender As Object, e As EventArgs) Handles txtP1First.Enter
txtP1First.ForeColor = Color.Black
If txtP1First.Text = "388" Then
txtP1First.Text = ""
Else
txtP1First.Text = txtP1First.Text
End If
statusLabel.Text = "Fill in the First Part of the Customers Main Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP1First TEXT BOX IS LEFT EMPTY
Private Sub txtP1First_Leave(sender As Object, e As EventArgs) Handles txtP1First.Leave
If txtP1First.Text Is "" Then
txtP1First.Text = "388"
txtP1First.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP1Last TEXT BOX IS CLICKED
Private Sub txtP1Last_Enter(sender As Object, e As EventArgs) Handles txtP1Last.Enter
txtP1Last.ForeColor = Color.Black
If txtP1Last.Text = "8755" Then
txtP1Last.Text = ""
Else
txtP1Last.Text = txtP1Last.Text
End If
statusLabel.Text = "Fill in the Last Part of the Customers Main Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP1Last TEXT BOX IS LEFT EMPTY
Private Sub txtP1Last_Leave(sender As Object, e As EventArgs) Handles txtP1Last.Leave
If txtP1Last.Text Is "" Then
txtP1Last.Text = "8755"
txtP1Last.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP2AreaCode TEXT BOX IS CLICKED
Private Sub txtP2AreaCode_Enter(sender As Object, e As EventArgs) Handles txtP2AreaCode.Enter
txtP2AreaCode.ForeColor = Color.Black
If txtP2AreaCode.Text = "507" Then
txtP2AreaCode.Text = ""
Else
txtP2AreaCode.Text = txtP2AreaCode.Text
End If
statusLabel.Text = "Fill in Area Code for the Customers Alternative Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP2AreaCode TEXT BOX IS LEFT EMPTY
Private Sub txtP2AreaCode_Leave(sender As Object, e As EventArgs) Handles txtP2AreaCode.Leave
If txtP2AreaCode.Text Is "" Then
txtP2AreaCode.Text = "507"
txtP2AreaCode.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP2First TEXT BOX IS CLICKED
Private Sub txtP2First_Enter(sender As Object, e As EventArgs) Handles txtP2First.Enter
txtP2First.ForeColor = Color.Black
If txtP2First.Text = "388" Then
txtP2First.Text = ""
Else
txtP2First.Text = txtP2First.Text
End If
statusLabel.Text = "Fill in the First Part of the Customers Alternative Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP2First TEXT BOX IS LEFT EMPTY
Private Sub txtP2First_Leave(sender As Object, e As EventArgs) Handles txtP2First.Leave
If txtP2First.Text Is "" Then
txtP2First.Text = "388"
txtP2First.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP2Last TEXT BOX IS CLICKED
Private Sub txtP2Last_Enter(sender As Object, e As EventArgs) Handles txtP2Last.Enter
txtP2Last.ForeColor = Color.Black
If txtP2Last.Text = "6665" Then
txtP2Last.Text = ""
Else
txtP2Last.Text = txtP2Last.Text
End If
statusLabel.Text = "Fill in the Last Part of the Customers Alternative Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP2Last TEXT BOX IS LEFT EMPTY
Private Sub txtP2Last_Leave(sender As Object, e As EventArgs) Handles txtP2Last.Leave
If txtP2Last.Text Is "" Then
txtP2Last.Text = "6665"
txtP2Last.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtComments TEXT BOX IS CLICKED
Private Sub txtComments_Enter(sender As Object, e As EventArgs) Handles txtComments.Enter
txtComments.ForeColor = Color.Black
If txtComments.Text = "Pleast enter any comments or special instructions about the job." Then
txtComments.Text = ""
Else
txtComments.Text = txtComments.Text
End If
statusLabel.Text = "Fill in any Extra Information the Customer may have Said"
End Sub
WHAT HAPPENS WHEN THE txtComments TEXT BOX IS LEFT EMPTY
Private Sub txtComments_Leave(sender As Object, e As EventArgs) Handles txtComments.Leave
If txtComments.Text Is "" Then
txtComments.Text = "Pleast enter any comments or special instructions about the job."
txtComments.ForeColor = Color.Gray
End If
End Sub
SELECT THE HOUR THAT THE CUSTOMER CALLED
Private Sub cbxTimeHour_Enter(sender As Object, e As EventArgs) Handles cbxTimeHour.Enter
statusLabel.Text = "Select the Hour that the Customer Called"
End Sub
CHECK THE STATE OF cbxTimeHour BEFORE ENABLING cbxTimeMinute
Private Sub cbxTimeHour_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxTimeHour.SelectedValueChanged
If cbxTimeHour.SelectedIndex = -1 Then
cbxTimeMinute.Enabled = False
Else
cbxTimeMinute.Enabled = True
End If
statusLabel.Text = "Select the Hour that the Customer Called"
End Sub
SELECT THE MINUTE (RANGE) THAT THE CUSTOMER CALLED
Private Sub cbxTimeMinute_Enter(sender As Object, e As EventArgs) Handles cbxTimeMinute.Enter
statusLabel.Text = "Select the Minute (Which ever is closer) that the Customer Called"
End Sub
CHECK THE STATE OF cbxTimeMinute BEFORE ENABLING cbxTimeAMPM
Private Sub cbxTimeMinute_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxTimeMinute.SelectedValueChanged
If cbxTimeMinute.SelectedIndex = -1 Then
cbxTimeAMPM.Enabled = False
Else
cbxTimeAMPM.Enabled = True
End If
End Sub
STATUSBAR TEXT TO SHOW WHEN THE MOUSE ENTERS THE CALENDAR
Private Sub monCalendar_MouseEnter(sender As Object, e As EventArgs) Handles monCalendar.MouseEnter
statusLabel.Text = "Select the Date that the Customer Called"
End Sub
HIDE THE STATUSBAR TEXT WHEN THE MOUSE LEAVES THE CALENDAR
Private Sub monCalendar_MouseLeave(sender As Object, e As EventArgs) Handles monCalendar.MouseLeave
statusLabel.Text = ""
End Sub
UNDO THE LAST OPERATION
Private Sub UndoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles UndoToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Undo()
End If
End Sub
REDO THE LAST OPERATION
Private Sub RedoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RedoToolStripMenuItem.Click
NEED TO ADD THE REDO CODE!!!!
End Sub
CUT THE TEXT FROM A TEXTBOX
Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CutToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Cut()
End If
End Sub
COPY THE TEXT TO THE CLIPBOARD
Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CopyToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Copy()
End If
End Sub
PASTE THE TEXT FROM THE CLIPBOARD
Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PasteToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Paste()
End If
End Sub
SELECT ALL THE TEXT IN THE TEXTBOX
Private Sub SelectAllToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SelectAllToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).SelectAll()
End If
End Sub
WHAT HAPPENS WHEN THE MOUSE HOVERS OVER THE SAVE BUTTON
Private Sub btnSave_MouseEnter(sender As Object, e As EventArgs) Handles btnSave.MouseEnter
statusLabel.Text = "Click here to save the information you have entered."
End Sub
WHAT HAPPENS WHEN THE MOUSE LEAVES THE SAVE BUTTON
Private Sub btnSave_MouseLeave(sender As Object, e As EventArgs) Handles btnSave.MouseLeave
statusLabel.Text = ""
End Sub
WHAT HAPPENS WHEN THE MOUSE HOVERS OVER THE CANCEL BUTTON
Private Sub btnCancel_MouseEnter(sender As Object, e As EventArgs) Handles btnCancel.MouseEnter
statusLabel.Text = "Click here to close the program"
End Sub
WHAT HAPPENS WHEN THE MOUSE LEAVES THE CANCEL BUTTON
Private Sub btnCancel_MouseLeave(sender As Object, e As EventArgs) Handles btnCancel.MouseLeave
statusLabel.Text = ""
End Sub
WHAT HAPPENS WHEN THE SAVE BUTTON IS CLICKED
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
End Sub
WHAT HAPPENS WHEN THE CANCEL BUTTON IS CLICKED
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Close()
End Sub
End Class
Sorry I know this is a long post but I figure someone will write back with a solution and I am going to have no idea what it means
I have a book that Im going through and learning but some of the stuff Im still having an issue wrapping my head around.
I have searched for solutions but grabbing sections from here and there can get a little confusing...
Thanks for the help I really appreciate it!!!
Ryan
Continue reading...
Im having trouble figuring out how to take the information on the form and save it to an XML File (I figured this part out) and than if the file exists already add the new information to the file.
Heres pictures of the two forms that I have.
The First (not start up window that shows up)
The Second (start up window) form that shows up
Hopefully you can get a good grasp of what Im trying to achieve here.
Heres the code that I have so far ( I know its still gonna need some work) :/
The code for the first (smaller) form
Public Class startWindow
Private strFileName As String
WHAT HAPPENS WHEN THE NEW BUTTON IS CLICKED
Private Sub btnNew_Click(sender As Object, e As EventArgs) Handles btnNew.Click
Me.Close()
mainWindow.Show()
End Sub
WHAT HAPPENS WHEN THE OPEN BUTTON IS CLICKED
Private Sub btnOpen_Click(sender As Object, e As EventArgs) Handles btnOpen.Click
Set ofdStartWindow Properties
With ofdStartWindow
.Filter = "Reichel Log (*.rei)|*.rei|All Files (*.*)|*.*"
.FilterIndex = 1
.Title = "Open Reichel Insulation - Lead Log File"
.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\nf"
End With
Show the ofdStartWindow dialog window
If ofdStartWindow.ShowDialog = Windows.Forms.DialogResult.OK Then
Try
Save the file path and name
strFileName = ofdStartWindow.FileName
txtLogLocation.Text = strFileName
Catch ex As Exception
MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End If
End Sub
ENABLE THE ACCEPT BUTTON ONLY IF THE TEXT BOX HAS A FILE LISTED
Private Sub txtLogLocation_TextChanged(sender As Object, e As EventArgs) Handles txtLogLocation.TextChanged
If txtLogLocation.Text = "" Then
btnContinue.Enabled = False
Else
btnContinue.Enabled = True
End If
End Sub
WHAT HAPPENS WHEN THE ACCEPT BUTTON IS CLICKED
Private Sub btnContinue_Click(sender As Object, e As EventArgs) Handles btnContinue.Click
Close()
mainWindow.Show()
End Sub
WHAT HAPPENS WHEN THE CANCEL BUTTON IS CLICKED
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
If txtLogLocation.Text = "" Then
mainWindow.Close()
Else
Dim ask As MsgBoxResult
ask = MessageBox.Show("Quit Without Saving?", My.Application.Info.Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If ask = MsgBoxResult.Yes Then
mainWindow.Close()
End If
End If
End Sub
End Class
The code for the Second (Bigger) form
Imports System.IO
Public Class mainWindow
DECLARE VARIABLES
Dim strFileName As String
MAIN WINDOW LOAD EVENT
Private Sub mainWindow_Load(sender As Object, e As EventArgs) Handles Me.Load
startWindow.ShowDialog()
End Sub
SALES REP COMBO BOX
Private Sub cbxRep_Enter(sender As Object, e As EventArgs) Handles cbxRep.Enter
statusLabel.Text = "Select the Sales Rep that this Lead will be going to."
End Sub
JOB TYPE COMBO BOX
Private Sub cbxJobType_Enter(sender As Object, e As EventArgs) Handles cbxJobType.Enter
statusLabel.Text = "Select the Type of Insulation Job that the Customer would like a Quote for."
End Sub
DISLPLAY THE statusLabel FOR cbxSource TEXT INFORMATION
Private Sub cbxSource_Click(sender As Object, e As EventArgs) Handles cbxSource.Click
statusLabel.Text = "Select where the customer heard about us From. Select other to input a custom place."
End Sub
ENABLE txtSource TEXT BOX IF OTHER IS SELECTED IN THE COMBO BOX
Private Sub cbxSource_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxSource.SelectedValueChanged
If cbxSource.SelectedItem = "Other" Then
txtSource.Enabled = True
Else
txtSource.Enabled = False
End If
End Sub
WHAT HAPPENS WHEN THE txtSource TEXT BOX IS CLICKED
Private Sub txtSource_Enter(sender As Object, e As EventArgs) Handles txtSource.Enter
txtSource.ForeColor = Color.Black
If txtSource.Text = "Other" Then
txtSource.Text = ""
Else
txtSource.Text = txtSource.Text
End If
statusLabel.Text = "Fill out the place where the customer heard about us"
End Sub
WHAT HAPPENS WHEN THE txtSource TEXT BOX IS LEFT EMPTY
Private Sub txtSource_Leave(sender As Object, e As EventArgs) Handles txtSource.Leave
If txtSource.Text Is "" Then
txtSource.Text = "Other"
txtSource.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE FirstName TEXT BOX IS CLICKED
Private Sub txtFirstName_Enter(sender As Object, e As EventArgs) Handles txtFirstName.Enter
txtFirstName.ForeColor = Color.Black
If txtFirstName.Text = "John" Then
txtFirstName.Text = ""
Else
txtFirstName.Text = txtFirstName.Text
End If
statusLabel.Text = "Fill in the Customers First Name"
End Sub
WHAT HAPPENS WHEN THE txtFirstName TEXT BOX IS LEFT EMPTY
Private Sub txtFirstName_Leave(sender As Object, e As EventArgs) Handles txtFirstName.Leave
If txtFirstName.Text Is "" Then
txtFirstName.Text = "John"
txtFirstName.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtLastName TEXT BOX IS CLICKED
Private Sub txtLastName_Enter(sender As Object, e As EventArgs) Handles txtLastName.Enter
txtLastName.ForeColor = Color.Black
If txtLastName.Text = "Doe" Then
txtLastName.Text = ""
Else
txtLastName.Text = txtLastName.Text
End If
statusLabel.Text = "Fill in the Customers Last Name"
End Sub
WHAT HAPPENS WHEN THE txtLastName TEXT BOX IS LEFT EMPTY
Private Sub txtLastName_Leave(sender As Object, e As EventArgs) Handles txtLastName.Leave
If txtLastName.Text Is "" Then
txtLastName.Text = "Doe"
txtLastName.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtAddress1 TEXT BOX IS CLICKED
Private Sub txtAddress1_Enter(sender As Object, e As EventArgs) Handles txtAddress1.Enter
txtAddress1.ForeColor = Color.Black
If txtAddress1.Text = "54040 Loren Dr." Then
txtAddress1.Text = ""
Else
txtAddress1.Text = txtAddress1.Text
End If
statusLabel.Text = "Fill in the Customers Address"
End Sub
WHAT HAPPENS WHEN THE txtAddress1 TEXT BOX IS LEFT EMPTY
Private Sub txtAddress1_Leave(sender As Object, e As EventArgs) Handles txtAddress1.Leave
If txtAddress1.Text Is "" Then
txtAddress1.Text = "54040 Loren Dr."
txtAddress1.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtAddress2 TEXT BOX IS CLICKED
Private Sub txtAddress2_Enter(sender As Object, e As EventArgs) Handles txtAddress2.Enter
txtAddress2.ForeColor = Color.Black
If txtAddress2.Text = "Mankato" Then
txtAddress2.Text = ""
Else
txtAddress2.Text = txtAddress2.Text
End If
statusLabel.Text = "Fill in the Customers City"
End Sub
WHAT HAPPENS WHEN THE txtAddress2 TEXT BOX IS LEFT EMPTY
Private Sub txtAddress2_Leave(sender As Object, e As EventArgs) Handles txtAddress2.Leave
If txtAddress2.Text Is "" Then
txtAddress2.Text = "Mankato"
txtAddress2.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtZipCode TEXT BOX IS CLICKED
Private Sub txtZipCode_Enter(sender As Object, e As EventArgs) Handles txtZipCode.Enter
txtZipCode.ForeColor = Color.Black
If txtZipCode.Text = "56001" Then
txtZipCode.Text = ""
Else
txtZipCode.Text = txtZipCode.Text
End If
statusLabel.Text = "Fill in the Customers Zip Code"
End Sub
WHAT HAPPENS WHEN THE txtZipCode TEXT BOX IS LEFT EMPTY
Private Sub txtZipCode_Leave(sender As Object, e As EventArgs) Handles txtZipCode.Leave
If txtZipCode.Text Is "" Then
txtZipCode.Text = "56001"
txtZipCode.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtBusinessName TEXT BOX IS CLICKED
Private Sub txtBusinessName_Enter(sender As Object, e As EventArgs) Handles txtBusinessName.Enter
txtBusinessName.ForeColor = Color.Black
If txtBusinessName.Text = "Reichel Insulation" Then
txtBusinessName.Text = ""
Else
txtBusinessName.Text = txtBusinessName.Text
End If
statusLabel.Text = "Fill in the Business Name"
End Sub
WHAT HAPPENS WHEN THE txtBusinessName TEXT BOX IS LEFT EMPTY
Private Sub txtBusinessName_Leave(sender As Object, e As EventArgs) Handles txtBusinessName.Leave
If txtBusinessName.Text Is "" Then
txtBusinessName.Text = "Reichel Insulation"
txtBusinessName.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtEmail TEXT BOX IS CLICKED
Private Sub txtEmail_Enter(sender As Object, e As EventArgs) Handles txtEmail.Enter
txtEmail.ForeColor = Color.Black
If txtEmail.Text = "someone@somewhere.com" Then
txtEmail.Text = ""
Else
txtEmail.Text = txtEmail.Text
End If
statusLabel.Text = "Fill in the Customers Email Address"
End Sub
WHAT HAPPENS WHEN THE txtEmail TEXT BOX IS LEFT EMPTY
Private Sub txtEmail_Leave(sender As Object, e As EventArgs) Handles txtEmail.Leave
If txtEmail.Text Is "" Then
txtEmail.Text = "someone@somewhere.com"
txtEmail.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP1AreaCode TEXT BOX IS CLICKED
Private Sub txtP1AreaCode_Enter(sender As Object, e As EventArgs) Handles txtP1AreaCode.Enter
txtP1AreaCode.ForeColor = Color.Black
If txtP1AreaCode.Text = "507" Then
txtP1AreaCode.Text = ""
Else
txtP1AreaCode.Text = txtP1AreaCode.Text
End If
statusLabel.Text = "Fill in the Area Code for the Customers Main Phone Number"
End Sub
Private Sub txtP1AreaCode_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtP1AreaCode.KeyPress
If Not Char.IsDigit(e.KeyChar) And Not Char.IsControl(e.KeyChar) Then
e.Handled = True
End If
End Sub
WHAT HAPPENS WHEN THE txtP1AreaCode TEXT BOX IS LEFT EMPTY
Private Sub txtP1AreaCode_Leave(sender As Object, e As EventArgs) Handles txtP1AreaCode.Leave
If txtP1AreaCode.Text Is "" Then
txtP1AreaCode.Text = "507"
txtP1AreaCode.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP1First TEXT BOX IS CLICKED
Private Sub txtP1First_Enter(sender As Object, e As EventArgs) Handles txtP1First.Enter
txtP1First.ForeColor = Color.Black
If txtP1First.Text = "388" Then
txtP1First.Text = ""
Else
txtP1First.Text = txtP1First.Text
End If
statusLabel.Text = "Fill in the First Part of the Customers Main Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP1First TEXT BOX IS LEFT EMPTY
Private Sub txtP1First_Leave(sender As Object, e As EventArgs) Handles txtP1First.Leave
If txtP1First.Text Is "" Then
txtP1First.Text = "388"
txtP1First.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP1Last TEXT BOX IS CLICKED
Private Sub txtP1Last_Enter(sender As Object, e As EventArgs) Handles txtP1Last.Enter
txtP1Last.ForeColor = Color.Black
If txtP1Last.Text = "8755" Then
txtP1Last.Text = ""
Else
txtP1Last.Text = txtP1Last.Text
End If
statusLabel.Text = "Fill in the Last Part of the Customers Main Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP1Last TEXT BOX IS LEFT EMPTY
Private Sub txtP1Last_Leave(sender As Object, e As EventArgs) Handles txtP1Last.Leave
If txtP1Last.Text Is "" Then
txtP1Last.Text = "8755"
txtP1Last.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP2AreaCode TEXT BOX IS CLICKED
Private Sub txtP2AreaCode_Enter(sender As Object, e As EventArgs) Handles txtP2AreaCode.Enter
txtP2AreaCode.ForeColor = Color.Black
If txtP2AreaCode.Text = "507" Then
txtP2AreaCode.Text = ""
Else
txtP2AreaCode.Text = txtP2AreaCode.Text
End If
statusLabel.Text = "Fill in Area Code for the Customers Alternative Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP2AreaCode TEXT BOX IS LEFT EMPTY
Private Sub txtP2AreaCode_Leave(sender As Object, e As EventArgs) Handles txtP2AreaCode.Leave
If txtP2AreaCode.Text Is "" Then
txtP2AreaCode.Text = "507"
txtP2AreaCode.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP2First TEXT BOX IS CLICKED
Private Sub txtP2First_Enter(sender As Object, e As EventArgs) Handles txtP2First.Enter
txtP2First.ForeColor = Color.Black
If txtP2First.Text = "388" Then
txtP2First.Text = ""
Else
txtP2First.Text = txtP2First.Text
End If
statusLabel.Text = "Fill in the First Part of the Customers Alternative Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP2First TEXT BOX IS LEFT EMPTY
Private Sub txtP2First_Leave(sender As Object, e As EventArgs) Handles txtP2First.Leave
If txtP2First.Text Is "" Then
txtP2First.Text = "388"
txtP2First.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtP2Last TEXT BOX IS CLICKED
Private Sub txtP2Last_Enter(sender As Object, e As EventArgs) Handles txtP2Last.Enter
txtP2Last.ForeColor = Color.Black
If txtP2Last.Text = "6665" Then
txtP2Last.Text = ""
Else
txtP2Last.Text = txtP2Last.Text
End If
statusLabel.Text = "Fill in the Last Part of the Customers Alternative Phone Number"
End Sub
WHAT HAPPENS WHEN THE txtP2Last TEXT BOX IS LEFT EMPTY
Private Sub txtP2Last_Leave(sender As Object, e As EventArgs) Handles txtP2Last.Leave
If txtP2Last.Text Is "" Then
txtP2Last.Text = "6665"
txtP2Last.ForeColor = Color.Gray
End If
End Sub
WHAT HAPPENS WHEN THE txtComments TEXT BOX IS CLICKED
Private Sub txtComments_Enter(sender As Object, e As EventArgs) Handles txtComments.Enter
txtComments.ForeColor = Color.Black
If txtComments.Text = "Pleast enter any comments or special instructions about the job." Then
txtComments.Text = ""
Else
txtComments.Text = txtComments.Text
End If
statusLabel.Text = "Fill in any Extra Information the Customer may have Said"
End Sub
WHAT HAPPENS WHEN THE txtComments TEXT BOX IS LEFT EMPTY
Private Sub txtComments_Leave(sender As Object, e As EventArgs) Handles txtComments.Leave
If txtComments.Text Is "" Then
txtComments.Text = "Pleast enter any comments or special instructions about the job."
txtComments.ForeColor = Color.Gray
End If
End Sub
SELECT THE HOUR THAT THE CUSTOMER CALLED
Private Sub cbxTimeHour_Enter(sender As Object, e As EventArgs) Handles cbxTimeHour.Enter
statusLabel.Text = "Select the Hour that the Customer Called"
End Sub
CHECK THE STATE OF cbxTimeHour BEFORE ENABLING cbxTimeMinute
Private Sub cbxTimeHour_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxTimeHour.SelectedValueChanged
If cbxTimeHour.SelectedIndex = -1 Then
cbxTimeMinute.Enabled = False
Else
cbxTimeMinute.Enabled = True
End If
statusLabel.Text = "Select the Hour that the Customer Called"
End Sub
SELECT THE MINUTE (RANGE) THAT THE CUSTOMER CALLED
Private Sub cbxTimeMinute_Enter(sender As Object, e As EventArgs) Handles cbxTimeMinute.Enter
statusLabel.Text = "Select the Minute (Which ever is closer) that the Customer Called"
End Sub
CHECK THE STATE OF cbxTimeMinute BEFORE ENABLING cbxTimeAMPM
Private Sub cbxTimeMinute_SelectedValueChanged(sender As Object, e As EventArgs) Handles cbxTimeMinute.SelectedValueChanged
If cbxTimeMinute.SelectedIndex = -1 Then
cbxTimeAMPM.Enabled = False
Else
cbxTimeAMPM.Enabled = True
End If
End Sub
STATUSBAR TEXT TO SHOW WHEN THE MOUSE ENTERS THE CALENDAR
Private Sub monCalendar_MouseEnter(sender As Object, e As EventArgs) Handles monCalendar.MouseEnter
statusLabel.Text = "Select the Date that the Customer Called"
End Sub
HIDE THE STATUSBAR TEXT WHEN THE MOUSE LEAVES THE CALENDAR
Private Sub monCalendar_MouseLeave(sender As Object, e As EventArgs) Handles monCalendar.MouseLeave
statusLabel.Text = ""
End Sub
UNDO THE LAST OPERATION
Private Sub UndoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles UndoToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Undo()
End If
End Sub
REDO THE LAST OPERATION
Private Sub RedoToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles RedoToolStripMenuItem.Click
NEED TO ADD THE REDO CODE!!!!
End Sub
CUT THE TEXT FROM A TEXTBOX
Private Sub CutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CutToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Cut()
End If
End Sub
COPY THE TEXT TO THE CLIPBOARD
Private Sub CopyToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles CopyToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Copy()
End If
End Sub
PASTE THE TEXT FROM THE CLIPBOARD
Private Sub PasteToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles PasteToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).Paste()
End If
End Sub
SELECT ALL THE TEXT IN THE TEXTBOX
Private Sub SelectAllToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SelectAllToolStripMenuItem.Click
If TypeOf Me.ActiveControl Is TextBox Then
CType(Me.ActiveControl, TextBox).SelectAll()
End If
End Sub
WHAT HAPPENS WHEN THE MOUSE HOVERS OVER THE SAVE BUTTON
Private Sub btnSave_MouseEnter(sender As Object, e As EventArgs) Handles btnSave.MouseEnter
statusLabel.Text = "Click here to save the information you have entered."
End Sub
WHAT HAPPENS WHEN THE MOUSE LEAVES THE SAVE BUTTON
Private Sub btnSave_MouseLeave(sender As Object, e As EventArgs) Handles btnSave.MouseLeave
statusLabel.Text = ""
End Sub
WHAT HAPPENS WHEN THE MOUSE HOVERS OVER THE CANCEL BUTTON
Private Sub btnCancel_MouseEnter(sender As Object, e As EventArgs) Handles btnCancel.MouseEnter
statusLabel.Text = "Click here to close the program"
End Sub
WHAT HAPPENS WHEN THE MOUSE LEAVES THE CANCEL BUTTON
Private Sub btnCancel_MouseLeave(sender As Object, e As EventArgs) Handles btnCancel.MouseLeave
statusLabel.Text = ""
End Sub
WHAT HAPPENS WHEN THE SAVE BUTTON IS CLICKED
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
End Sub
WHAT HAPPENS WHEN THE CANCEL BUTTON IS CLICKED
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Close()
End Sub
End Class
Sorry I know this is a long post but I figure someone will write back with a solution and I am going to have no idea what it means
I have a book that Im going through and learning but some of the stuff Im still having an issue wrapping my head around.
I have searched for solutions but grabbing sections from here and there can get a little confusing...
Thanks for the help I really appreciate it!!!
Ryan
Continue reading...