JTART2 11-16-2004, 02:13 PM I want to put check boxes on a form so that when it is checked, a nearby blank text box with a default value of zero will show a new amount, e.g. Text Box = 0, after clicking check box, text box = $100
How do I program this in VB.Net
When I try, I get compile errors.
Thanks for any help!
Jtart2
Hi Jtart2,
Welcome to the Forum.
For the answer to your question :
Have a form with a Textbox and Checkbox.
Get the checked property of the checkbox and set the text property of textbox.
See if this helps.
SSK
JTART2 11-19-2004, 08:05 PM Thanks for the suggestion, and it helped, however, instead of getting 100, I get either "-1" if the checkbox is checked, or a "True"
I need a specific amount put into the textbox.
Say someone wants to buy a specific can of dog food listed on the form, e.g. ALPO, and when the ALPO checkbox is checked, the ALPO textbox pops up $2.00. How do I do this?
Thanks for your help in advance!!!
JTART2
Hi Jtart2,
Welcome to the Forum.
For the answer to your question :
Have a form with a Textbox and Checkbox.
Get the checked property of the checkbox and set the text property of textbox.
See if this helps.
SSK
herilane 11-21-2004, 12:53 PM I'm sorry, I don't understand - how does MS Access come into this?
JTART2 11-21-2004, 09:29 PM This is taking place on a MS Access form with lots of textboxes and checkboxes. I want to be able to click a checkbox and have a default value passed to a textbox.
Deadalus 11-22-2004, 05:14 AM Something like this?
Const ALPOPRICE = 5
Private Sub chkAlpo_Click()
If chkAlpo.Value = True Then
txtPrice = ALPOPRICE
'or if you want to add it
'txtPrice = Val(txtPrice.Value) + ALPOPRICE
'if you need to subtract it when unchecked
Else
txtPrice.Value = Val(txtPrice.Value) - ALPOPRICE
End If
End Sub
JTART2 11-22-2004, 09:20 PM This looks like it may work. I'll give it a try and let you know how it goes.
Thanks for your help!!!
Jtart2
Something like this?
Const ALPOPRICE = 5
Private Sub chkAlpo_Click()
If chkAlpo.Value = True Then
txtPrice = ALPOPRICE
'or if you want to add it
'txtPrice = Val(txtPrice.Value) + ALPOPRICE
'if you need to subtract it when unchecked
Else
txtPrice.Value = Val(txtPrice.Value) - ALPOPRICE
End If
End Sub
JTART2 11-22-2004, 10:00 PM The way I have managed to work it so far...when the form pops up, the checkbox is already checked, and the price is already showing in the textbox. Which is fine if everybody only wants Alpo. When I check the checkbox and make the check disappear, the textbox clears to zero.
When I try to put the check back in the checkbox, nothing happens (no check in checkbox, and no price in textbox)
I'm making progress, but there is something still missing.
I want the defaults to be "unchecked" and textbox at "0" When I check the checkbox, the textbox should pop up the price every time, and disappear when I uncheck the box.
Anybody got any more ideas... they are greatly appreciated!
Jtart2
Deadalus 11-23-2004, 02:17 AM The way I have managed to work it so far...when the form pops up, the checkbox is already checked, and the price is already showing in the textbox. Which is fine if everybody only wants Alpo. When I check the checkbox and make the check disappear, the textbox clears to zero.
If you want to add the price, just adapt the code to do that, like I did in the Else part to subtract it.
When I try to put the check back in the checkbox, nothing happens (no check in checkbox, and no price in textbox)
I don't understand that. Show your code.
|