Im doing a project where I have to create a form for trash cans. I have everything working but on my order page i need to get the information from the listboxes in my first page purchase button. Any help would be appreciated. btnAdd_Click is where im trying to get the info from and btnFinish is where i need it to be able to be read.
Code:
Option Strict On
Option Infer Off
Option Explicit On
Public Class Form1
Public Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim a As Integer = 0
Do
lb1.Items.Add(a)
a += 1
Loop Until (a > 500)
Dim b As Integer = 0
Do
lb2.Items.Add(b)
b += 1
Loop Until (b > 500)
Dim c As Integer = 0
Do
lb3.Items.Add(c)
c += 1
Loop Until (c > 500)
btnAdd.Visible = False
btn1.Visible = False
btn3.Visible = False
lb1.Visible = False
lb2.Visible = False
lb3.Visible = False
btnBack.Visible = False
lb2.SelectedIndex = 0
lb3.SelectedIndex = 0
lb1.SelectedIndex = 0
lblPassword.Visible = False
txtpassword.Visible = False
btnpassword.Visible = False
lblgarbage.Visible = False
lblrecycling.Visible = False
lblewaste.Visible = False
lblFirstLast.Visible = False
lblNum.Visible = False
lblStreetName.Visible = False
lblCity.Visible = False
lblState.Visible = False
lblZip.Visible = False
txtBoxFirstLast.Visible = False
txtBoxNum.Visible = False
txtBoxStreetName.Visible = False
txtBoxCity.Visible = False
txtBoxState.Visible = False
txtBoxZip.Visible = False
pic4.Visible = False
btnSubmit.Visible = False
rb1.Visible = False
rb2.Visible = False
btnSend.Visible = False
btnClearOrder.Visible = False
btnFinish.Visible = False
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btn1.Click
lblTotal.Text = ""
lbl2.Text = ""
End Sub
Private Sub btn3_Click(sender As Object, e As EventArgs) Handles btn3.Click
Me.Close()
End Sub
Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btn2_Click(sender As Object, e As EventArgs) Handles btn2.Click
btnAdd.Visible = True
btn3.Visible = True
lb1.Visible = True
lb2.Visible = True
lb3.Visible = True
btn2.Visible = False
btnExit.Visible = False
btn1.Visible = False
btnBack.Visible = True
lblgarbage.Visible = True
lblrecycling.Visible = True
lblewaste.Visible = True
If cb1.CheckState = 0 Then
cb1.Visible = False
pic1.Visible = False
lb1.Visible = False
End If
If cb2.CheckState = 0 Then
cb2.Visible = False
pic2.Visible = False
lb2.Visible = False
End If
If cb3.CheckState = 0 Then
cb3.Visible = False
pic3.Visible = False
lb3.Visible = False
End If
If cb1.CheckState = 0 And cb2.CheckState = 0 And cb3.CheckState = 0 Then
MessageBox.Show("Please choose at least one container Press Refresh to do so!!!")
End If
End Sub
Public Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
btnSubmit.Visible = True
btn1.Visible = True
btnAdd.Visible = False
Dim result1 As Double
Dim result2 As Double
Dim result3 As Double
Dim result4 As Double
Dim result5 As Double
Dim result6 As Double
If lb1.SelectedIndex <= 500 Then
result1 = lb1.SelectedIndex
End If
If lb2.SelectedIndex <= 500 Then
result2 = lb2.SelectedIndex
End If
If lb3.SelectedIndex <= 500 Then
result3 = lb3.SelectedIndex
End If
If lb1.SelectedIndex <= 500 Then
result4 = lb1.SelectedIndex * 25
'MessageBox.Show("Here is result4 " & result4)
End If
If lb2.SelectedIndex <= 500 Then
result5 = CDbl(lb2.SelectedIndex) * 45
' MessageBox.Show(result5.ToString)
' MessageBox.Show(result4.ToString)
' MessageBox.Show(result6.ToString)
End If
If lb3.SelectedIndex <= 500 Then
result6 = lb3.SelectedIndex * 25
End If
If cb1.CheckState = 1 Or cb2.CheckState = 1 Or cb3.CheckState = 1 Then
lblTotal.Text = "You have ordered " & (result1) & " garbage containers, " & (result2) & " recycling containers, " & "and " & (result3) & " e-waste containers" & ControlChars.NewLine & "Your total due is " & FormatCurrency(result4 + result5 + result6) & ControlChars.NewLine & " if this is correct please click Submit Order"
End If
If cb1.CheckState = 0 Or cb2.CheckState = 0 Or cb3.CheckState = 0 Then
lb2.Text = ""
ElseIf result1 + result2 + result3 < 200 Then
MessageBox.Show("You have selected less than 200 total containers please refresh and order more than 200 Thank you")
lblTotal.Text = ""
End If
If cb1.CheckState = 0 Then
lb2.Text = ""
ElseIf lb1.SelectedIndex < 50 Then
lblPassword.Visible = True
txtpassword.Visible = True
btnpassword.Visible = True
btnSubmit.Visible = False
MessageBox.Show("you selected less than 50 garbage containers please enter password")
End If
If cb2.CheckState = 0 Then
lb2.Text = ""
ElseIf lb2.SelectedIndex < 50 Then
lblPassword.Visible = True
txtpassword.Visible = True
btnpassword.Visible = True
btnSubmit.Visible = False
MessageBox.Show("you selected less than 50 recycling containers please enter password")
End If
If cb3.CheckState = 0 Then
lb2.Text = ""
ElseIf lb3.SelectedIndex < 50 Then
lblPassword.Visible = True
txtpassword.Visible = True
btnpassword.Visible = True
btnSubmit.Visible = False
MessageBox.Show("you selected less than 50 e-waste containers please enter password")
End If
lb1.ClearSelected()
lb2.ClearSelected()
lb3.ClearSelected()
lb1.Visible = False
lb2.Visible = False
lb3.Visible = False
End Sub
Private Sub btnBack_Click(sender As Object, e As EventArgs) Handles btnBack.Click
cb1.Visible = True
pic1.Visible = True
cb2.Visible = True
pic2.Visible = True
cb3.Visible = True
pic3.Visible = True
btnAdd.Visible = False
btnExit.Visible = True
btn1.Visible = False
btn2.Visible = True
btn3.Visible = False
lb1.Visible = False
lb2.Visible = False
lb3.Visible = False
lb1.ClearSelected()
lb2.ClearSelected()
lb3.ClearSelected()
cb1.CheckState = 0
cb2.CheckState = 0
cb3.CheckState = 0
lblTotal.Text = ""
lb2.SelectedIndex = 0
lb3.SelectedIndex = 0
lb1.SelectedIndex = 0
lblPassword.Visible = False
txtpassword.Visible = False
btnpassword.Visible = False
btnpassword.Visible = False
txtpassword.Text = ""
lblFirstLast.Visible = False
lblNum.Visible = False
lblStreetName.Visible = False
lblCity.Visible = False
lblState.Visible = False
lblZip.Visible = False
txtBoxFirstLast.Visible = False
txtBoxNum.Visible = False
txtBoxStreetName.Visible = False
txtBoxCity.Visible = False
txtBoxState.Visible = False
txtBoxZip.Visible = False
pic4.Visible = False
btnSubmit.Visible = False
rb1.Visible = False
rb2.Visible = False
btnSend.Visible = False
btnClearOrder.Visible = False
btnFinish.Visible = False
End Sub
Private Sub bynpasswordenter_Click(sender As Object, e As EventArgs) Handles btnpassword.Click
If txtpassword.Text = "Snoopy" Then
btnSubmit.Visible = True
lbl2.Text = "Thank you password is correct"
Else
lbl2.Text = "sorry wrong password try again"
End If
End Sub
Private Sub btnSubmitOrder_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
cb1.Visible = False
cb2.Visible = False
cb3.Visible = False
pic1.Visible = False
pic2.Visible = False
pic3.Visible = False
lblgarbage.Visible = False
lblrecycling.Visible = False
lblewaste.Visible = False
btn1.Visible = False
lblTotal.Visible = False
lblPassword.Visible = False
btnpassword.Visible = False
txtpassword.Visible = False
btn3.Visible = False
btnFinish.Visible = True
btnClearOrder.Visible = True
btnExit.Visible = True
btnSend.Visible = True
lblFirstLast.Visible = True
lblNum.Visible = True
lblStreetName.Visible = True
lblCity.Visible = True
lblState.Visible = True
lblZip.Visible = True
txtBoxFirstLast.Visible = True
txtBoxNum.Visible = True
txtBoxStreetName.Visible = True
txtBoxCity.Visible = True
txtBoxState.Visible = True
txtBoxZip.Visible = True
pic4.Visible = True
btnSubmit.Visible = True
rb1.Visible = True
rb2.Visible = True
btnSubmit.Visible = False
End Sub
Private Sub btnClearOrder_Click(sender As Object, e As EventArgs) Handles btnClearOrder.Click
txtBoxFirstLast.Text = ""
txtBoxNum.Text = ""
txtBoxStreetName.Text = ""
txtBoxCity.Text = ""
txtBoxState.Text = ""
txtBoxZip.Text = ""
rb1.Checked = False
rb2.Checked = False
End Sub
Public Sub btnFinish_Click(sender As Object, e As EventArgs) Handles btnFinish.Click
Dim result1 As Double
Dim result2 As Double
Dim result3 As Double
Dim result4 As Double
Dim result5 As Double
Dim result6 As Double
Dim radio1 As String
result1 = lb1.SelectedIndex
result2 = lb2.SelectedIndex
result3 = lb3.SelectedIndex
radio1 = ""
If rb1.Checked Then
radio1 = rb1.Text
Else
radio1 = rb2.Text
End If
lblFinal.Text = txtBoxFirstLast.Text & ControlChars.NewLine & "You have ordered " & (result1) & " garbage containers, " & (result2) & " recycling containers, " & "and " & (result3) & " e-waste containers" & ControlChars.NewLine & "With " & radio1 & ControlChars.NewLine & "Your total due is " & FormatCurrency(result4 + result5 + result6) & ControlChars.NewLine & "Your Order with be shipped to:" & ControlChars.NewLine & txtBoxFirstLast.Text & ControlChars.NewLine & txtBoxNum.Text & " " & txtBoxStreetName.Text & ControlChars.NewLine & txtBoxCity.Text & ", " & txtBoxState.Text & ControlChars.NewLine & txtBoxZip.Text & ControlChars.NewLine & "Please click Send Order!!!"
End Sub
Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
MessageBox.Show("Thank You for your Business, Your Shipment is now being filled and will arrive shortly" & ControlChars.NewLine & "Sincerely California Garbage Can Maker")
Me.Close()
End Sub
End Class