If statment problem
-
Im having issues with my if statments for this program. I have 3 ratiobuttons, each one should do a different task. The first one works alright, but now the 2nd one will not work because of the logic i believe. It should deduct the value from label3.text, only if label3 is higher then the amount of the cheque which is Textbox1 If the value of textbox1 is higher then label3 it has to display a messagebox saying insuficient funds. and then deduct a service charge which is declared as 10$ Here is my code. if anyone is able to assist, it would be greatly appreciated. Dim servicecharge As Integer Dim transaction As Integer Dim Balance As Integer ' Declare the value of service charge servicecharge = 10 transaction = TextBox1.Text Balance = Label3.Text ' Deposit Funds to the account If RadioButton1.Checked = True Then Label3.Text = TextBox1.Text End If ' Process a cheque through the account, confirming sufficient funds, If returned NSF the account ' will not be deducted the amount of the cheque, but will be charged 10 dollars. If RadioButton2.Checked = True Then Balance = Balance - transaction ElseIf transaction > Balance Then MessageBox.Show("Insufficient Funds") Label3.Text = Label3.Text - servicecharge End If ' Service charge processed on the account. If RadioButton3.Checked = True Then Label3.Text = Label3.Text - servicecharge End If End Sub
-
Im having issues with my if statments for this program. I have 3 ratiobuttons, each one should do a different task. The first one works alright, but now the 2nd one will not work because of the logic i believe. It should deduct the value from label3.text, only if label3 is higher then the amount of the cheque which is Textbox1 If the value of textbox1 is higher then label3 it has to display a messagebox saying insuficient funds. and then deduct a service charge which is declared as 10$ Here is my code. if anyone is able to assist, it would be greatly appreciated. Dim servicecharge As Integer Dim transaction As Integer Dim Balance As Integer ' Declare the value of service charge servicecharge = 10 transaction = TextBox1.Text Balance = Label3.Text ' Deposit Funds to the account If RadioButton1.Checked = True Then Label3.Text = TextBox1.Text End If ' Process a cheque through the account, confirming sufficient funds, If returned NSF the account ' will not be deducted the amount of the cheque, but will be charged 10 dollars. If RadioButton2.Checked = True Then Balance = Balance - transaction ElseIf transaction > Balance Then MessageBox.Show("Insufficient Funds") Label3.Text = Label3.Text - servicecharge End If ' Service charge processed on the account. If RadioButton3.Checked = True Then Label3.Text = Label3.Text - servicecharge End If End Sub
PLease, please tell me this is not your actual code ? You have variables called RadioButton1 and RadioButton2 ?
aerosmith2k1 wrote:
If RadioButton1.Checked = True Then
If the first button is checked, do this
aerosmith2k1 wrote:
If RadioButton2.Checked = True Then
If the second one is checked do this ( even if the first was checked )
aerosmith2k1 wrote:
ElseIf transaction > Balance Then
If radio button 2 is NOT checked ( that's what the elif does ) AND transaction > balance, then do this
aerosmith2k1 wrote:
If RadioButton3.Checked = True Then
If radio button 3 is checked, no matter if the others are, do this. I suspect your radio buttons work so only one can be checked, but I'd still do an elif to define the three radio button steps. It makes the code more efficient. And, I think the elif you ARE using, is your problem. Have you tried stepping through the code in the debugger to see what happens, and how it differs from what you expect ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Im having issues with my if statments for this program. I have 3 ratiobuttons, each one should do a different task. The first one works alright, but now the 2nd one will not work because of the logic i believe. It should deduct the value from label3.text, only if label3 is higher then the amount of the cheque which is Textbox1 If the value of textbox1 is higher then label3 it has to display a messagebox saying insuficient funds. and then deduct a service charge which is declared as 10$ Here is my code. if anyone is able to assist, it would be greatly appreciated. Dim servicecharge As Integer Dim transaction As Integer Dim Balance As Integer ' Declare the value of service charge servicecharge = 10 transaction = TextBox1.Text Balance = Label3.Text ' Deposit Funds to the account If RadioButton1.Checked = True Then Label3.Text = TextBox1.Text End If ' Process a cheque through the account, confirming sufficient funds, If returned NSF the account ' will not be deducted the amount of the cheque, but will be charged 10 dollars. If RadioButton2.Checked = True Then Balance = Balance - transaction ElseIf transaction > Balance Then MessageBox.Show("Insufficient Funds") Label3.Text = Label3.Text - servicecharge End If ' Service charge processed on the account. If RadioButton3.Checked = True Then Label3.Text = Label3.Text - servicecharge End If End Sub
If RadioButton1.Checked = True Then Label3.Text = TextBox1.Text End If If RadioButton2.checked then If lbl3.value > textbox1.value then Balance = Balance - transaction Elseif textbox1.value > label3.value Then MessageBox.Show("Insufficient Funds") Label3.Text = Label3.Text - servicecharge End if End if If RadioButton3.Checked = True Then Label3.Text = Label3.Text - servicecharge End If If I am not wrong at getting your logic ,You can try this one:omg:
Develop2Program & Program2Develop
-
If RadioButton1.Checked = True Then Label3.Text = TextBox1.Text End If If RadioButton2.checked then If lbl3.value > textbox1.value then Balance = Balance - transaction Elseif textbox1.value > label3.value Then MessageBox.Show("Insufficient Funds") Label3.Text = Label3.Text - servicecharge End if End if If RadioButton3.Checked = True Then Label3.Text = Label3.Text - servicecharge End If If I am not wrong at getting your logic ,You can try this one:omg:
Develop2Program & Program2Develop
I greatly appreciate your help, very Patient :)