flame1987
Member
Registered: 20th Nov 06
Location: North Wales
User status: Offline
|
i need some help probably very easy but head it battered at the minute and cant think straight
Basically i need to perform a calculation for a deposit based on a combo box answer and the total value
e.g
if combobox = yes then
deposit must be 10% of total amount
using visual studio too, thanks
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
What language?
You have the idea -
if combo.value = 'yes' then
deposit = amount x 0.1
else
deposit = 0
That won't run of course - you need to sort the syntax.
[Edited on 10-05-2007 by Ian]
|
flame1987
Member
Registered: 20th Nov 06
Location: North Wales
User status: Offline
|
Sorry .net
|
flame1987
Member
Registered: 20th Nov 06
Location: North Wales
User status: Offline
|
I currently have this
If DepositAmountTextBox.Text <= AmountToBorrowTextBox.Text * 5 / 100 Then
ErrorProvider1.SetError(DepositAmountTextBox, "You must enter at least 5%")
Else
ErrorProvider1.SetError(DepositAmountTextBox, "")
But need it to only work when yes has been selected from a combo box
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
If combobox value and all that stuff?
|
JamesMG
Member
Registered: 14th Nov 06
Location: Newcastle-under-Lyme, Staffordshire
User status: Offline
|
you can enclose if statements within if statements..
so the first would check the status of the combo, either yes or no.. if no then msgbox.. do nothing etc..
if the value is yes then u can enclose another if statement which checks the values..
*edit*
Like so...
if combo1.value = "yes" then
if text2.text = "yes" then
shape1.backcolor = vbGreen
else
shape1.backcolor = vbRed
end if
end if
like that... there are a few limitations however but its probably the easiest way to do it..
[Edited on 11-05-2007 by JamesMG]
|
Paul_J
Member
Registered: 6th Jun 02
Location: London
User status: Offline
|
quote: Originally posted by flame1987
I currently have this
If DepositAmountTextBox.Text <= AmountToBorrowTextBox.Text * 5 / 100 Then
ErrorProvider1.SetError(DepositAmountTextBox, "You must enter at least 5%")
Else
ErrorProvider1.SetError(DepositAmountTextBox, "")
But need it to only work when yes has been selected from a combo box
That's nothing like the example you gave above
Use 2 radio buttons then... 1 saying yes, 1 saying no.
If Radiobutton1.Checked = True then
If ((DepositAmountTextBox.Text) <= (AmountToBorrowTextBox.Text * (5 / 100))) Then
ErrorProvider1.SetError(DepositAmountTextBox, "You must enter at least 5%")
Else
ErrorProvider1.SetError(DepositAmountTextBox, "")
End If
End If
I don't have my copy of visual stuido on this pc, so can't remember exact syntax... Do you need begin and end's in this ? lol
VB.net I assume? I'd use Message boxes instead of error providers.
[Edited on 11-05-2007 by Paul_J]
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
Not familiar with the syntax but it would make more sense to combine the conditions in one if statement?
if combo and amount then ...
|
flame1987
Member
Registered: 20th Nov 06
Location: North Wales
User status: Offline
|
dont really want to use message boxes as there re 15 other formsof validation going on. So used errorprovider to prevent loads of messageboxes.
If CDec(DepositAmountTextBox.Text <= AmountToBorrowTextBox.Text * 5 / 100) And FirstTimeBuyerComboBox.Text = "Yes" Then
ErrorProvider1.SetError(DepositAmountTextBox, "You must enter at least 5%")
Exit Sub
Else
ErrorProvider1.SetError(DepositAmountTextBox, "")
End If
This statement seems to work
|