[RESOLVED] Problem with checkbox & radio buttons...
Half the problem solved, but now I need,
If GlassRadioButton.Checked = True Then
, well here's where im stuck, I need Glass to get added to a string or something, so it can be called in myAddNew
?
vb.net Code:
"VALUES"
Dim myValue As Integer ' Base value of frames
Dim myValue1 As Integer ' Glass or plastic value
Dim myValue2 As Integer ' Scratch Coating value
Dim myValue3 As Integer ' UV value
Dim totalCost As Integer ' Total value
Dim deposit As Integer ' Deposit value, 20% of total
myValue = 50 'Base value of frames, always 50
If GlassRadioButton.Checked = True Then
myValue1 = 30
ElseIf
PlasticRadioButton.Checked = True Then
myValue1 = 15
End If
If CheckBox1.Checked = True Then
myValue2 = 10
Else
myValue2 = 0
End If
If CheckBox2.Checked = True Then
myValue3 = 15
Else
myValue3 = 0
End If
totalCost = myValue + myValue1 + myValue2 + myValue3 'Gets total by adding all values
deposit = totalCost * 0.2 'Divides total by 0.2 to find the 20% deposit
TextBox1.Text = totalCost 'Displays total
TextBox2.Text = deposit 'Displays deposit
TextBox3.Text = totalCost - deposit 'Subtracts the deposit from total, to find balance
PrintButton.Enabled = True
ViewButton.Enabled = True
myAddNew(8) 'CALLS ADDNEW METHOD WHEN ADD BUTTON IS CLICKED
Re: Problem with checkbox & radio buttons...
have you set a break point and steped though the code? Set it on the first line myValue = 50 then step though line by line and watch what happens to the different values.
Re: Problem with checkbox & radio buttons...
ok redone the OP code so its clearer
Code:
Dim myValue As Integer ' Base value of frames
Dim myValue1 As Integer ' Glass or plastic value
Dim myValue2 As Integer ' Scratch Coating value
Dim myValue3 As Integer ' UV value
Dim totalCost As Integer ' Total value
Dim deposit As Integer ' Deposit value, 20% of total
myValue = 50 'Base value of frames, always 50
If GlassRadioButton.Checked = True Then
myValue2 = 30
ElseIf
PlasticRadioButton.Checked = True Then
myValue2 = 15
End If
If CheckBox1.Checked = True Then
myValue2 = 10
Else
myValue2 = 0
End If
If CheckBox2.Checked = True Then
myValue3 = 15
Else
myValue3 = 0
End If
totalCost = myValue + myValue1 + myValue2 + myValue3 'Gets total by adding all values
deposit = totalCost * 0.2 'Divides total by 0.2 to find the 20% deposit
TextBox1.Text = totalCost 'Displays total
TextBox2.Text = deposit 'Displays deposit
TextBox3.Text = totalCost - deposit 'Subtracts the deposit from total, to find balance
PrintButton.Enabled = True
ViewButton.Enabled = True
myAddNew(8) 'CALLS ADDNEW METHOD WHEN ADD BUTTON IS CLICKED
Re: Problem with checkbox & radio buttons...
Figured it, I had myValue2 being used in 2 different places, when it should have been myValue1 for Glass or Plastic...
Wondering how can I make it now so that these values get saved to use in myAddNew?
I had it working as GPTextBox and if I typed glass or plastic in, I had it in myAddNew as GPTextBox.Text corrosponding to Material
Re: Problem with checkbox & radio buttons...
what is myAddNew a procedure you wrote? What is 8 in the call?
Re: Problem with checkbox & radio buttons...
Quote:
Okay, for some reason... the Radio button doesn't work when the checkboxes do
ok well not sure what you mean by not work? is this you click one radio button then when you click another one they both are selected?
Re: Problem with checkbox & radio buttons...
It's working fine now Megalith, my problem was I had a checkbox updating the myValue2 data... and also had a radio button updating it... overlap of error!
Re: Problem with checkbox & radio buttons...
Quote:
Originally Posted by
GaryMazzone
what is myAddNew a procedure you wrote? What is 8 in the call?
Add Code:
Private Sub myAddNew(ByVal CusRef As Integer)
Dim ConnectionString As String
Dim SQLString As String
Dim whichButtonDialogResult As DialogResult
Dim dbCommand As System.Data.OleDb.OleDbCommand
Dim Connection As System.Data.OleDb.OleDbConnection
ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data "
ConnectionString += "Source=" & "Opticians.accdb "
Connection = New System.Data.OleDb.OleDbConnection(ConnectionString)
SQLString = "INSERT INTO SpecSalesTable (CustomerID, EyeTestID, FrameID, DateOfSale, GlassOrPlastic, ScratchCoating, UVFilter, TotalCost, DepositPaid) "
SQLString += "Values ('" & CustomerIDTextBox.Text & "','" & EyeTestIDTextBox.Text & "','" & StockTextBox.Text & "',#" & Date.Today & "#,'" & GlassPlasticTextBox.Text & "','" & ScratchTextBox.Text & "','" & UVTextBox.Text & "','" & TextBox1.Text & "','" & TextBox2.Text & "')"
whichButtonDialogResult = MessageBox.Show("Are You Sure You Want To Place This Order?", "Add Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If whichButtonDialogResult = DialogResult.Yes Then
Connection.Open()
If CBool(ConnectionState.Open) Then
dbCommand = New System.Data.OleDb.OleDbCommand(SQLString, Connection)
Try
dbCommand.ExecuteNonQuery()
MessageBox.Show("Order placed, SpecSalesTable Updated! ")
Catch ex As Exception
MessageBox.Show(" Error placing order... ") 'IF ERROR DISPLAYS MESSAGE
End Try
End If
End If
Connection.Close()
End Sub
If I'm being completely honest, I don't understand what the 8 is there for, just needed an integer or else I got errors from it :eek2:
Re: Problem with checkbox & radio buttons...
Code:
Dim totalCost As Integer ' Total value
Dim deposit As Integer ' Deposit value, 20% of total
totalCost= 50 'Base value of frames, always 50
Select Case GPCboBx.Text ' Combobox Text
Case "Glass"
totalCost += 30
Case "Plastic"
totalCost += 15
End Select
Select Case ScratchCboBx.Text ' Combobox Text
Case "Yes"
totalCost += 10
End Select
Select Case UVCboBx.Text ' Combobox Text
Case "Yes"
totalCost += 15
End Select
deposit = totalCost * 0.2 'Divides total by 0.2 to find the 20% deposit
TextBox1.Text = totalCost 'Displays total
TextBox2.Text = deposit 'Displays deposit
TextBox3.Text = totalCost - deposit 'Subtracts the deposit from total, to find balance
PrintButton.Enabled = True
ViewButton.Enabled = True
myAddNew(8) 'CALLS ADDNEW METHOD WHEN ADD BUTTON IS CLICKED
Then create variables in your "myAddNew" method for the values you wish to use in it.
Re: Problem with checkbox & radio buttons...
Lets start with these two lines (really the second one I guess)
Code:
SQLString = "INSERT INTO SpecSalesTable (CustomerID, EyeTestID, FrameID, DateOfSale, GlassOrPlastic, ScratchCoating, UVFilter, TotalCost, DepositPaid) "
SQLString += "Values ('" & CustomerIDTextBox.Text & "','" & EyeTestIDTextBox.Text & "','" & StockTextBox.Text & "',#" & Date.Today & "#,'" & GlassPlasticTextBox.Text & "','" & ScratchTextBox.Text & "','" & UVTextBox.Text & "','" & TextBox1.Text & "','" & TextBox2.Text & "')"
GlassPlasticTextBox : We are not using this any more so
in the Dim section lets decalare a new variable
vb.net Code:
DIM glassOrPlasting as STRING = String.Empty
Next we text the radiobuton
vb.net Code:
IF GlassRadioButton.Checked = True Then
glassOrPlastic = "Glass Lens"
ELSEIF PlasticRadioButton.Checked = True Then
glassOrPlastic = "Plastic Lens"
ELSE
glassOrPlastic = "What do you mean?"
END IF
Now you replace GlassPlasticTextBox.Text with the glassOrPlastic variable
Does this give you an idea to carry on with?
Re: Problem with checkbox & radio buttons...
Gary, can't thank you enough...!