buttons 
Author Message
 buttons

Can a command button be pressed and a variable be set to a
number? I want to make a button that shows a discount 16
percent as the button lable. If pressed I want to have a
variable set to 16. Do I do this with an if statement? I
tried and failed.
I tried the If -(I do not know what the function of click
is to tell it) then set variable =16. I tried the default
of .F. and if command1 = .F. then vairable =16

Somehow I think I am doing this wrong.
PS> I am an old basic programer that bought FoxPro to
sharpen my skills (Which I find are non-existant in oop
programing)
Thanks,
Mike



Sat, 03 Sep 2005 22:13:01 GMT  
 buttons
In short the button will have a CLICK method.

In the Click method put code like

lnVariable = 16

It may be better to create a subclass of the CommandButtton and add a
property, something like nPercent, set initially to 0

The CLICK method could then have code like

this.nPercent = 16

or, if you want to be smart

this.nPercent = iif(this.nPercent = 0, 16, 0)

to enable you to toggle.

An Option might be even better.

Andrew R.


Quote:
> Can a command button be pressed and a variable be set to a
> number? I want to make a button that shows a discount 16
> percent as the button lable. If pressed I want to have a
> variable set to 16. Do I do this with an if statement? I
> tried and failed.
> I tried the If -(I do not know what the function of click
> is to tell it) then set variable =16. I tried the default
> of .F. and if command1 = .F. then vairable =16

> Somehow I think I am doing this wrong.
> PS> I am an old basic programer that bought FoxPro to
> sharpen my skills (Which I find are non-existant in oop
> programing)
> Thanks,
> Mike



Sat, 03 Sep 2005 22:39:07 GMT  
 buttons
Hi Mike,

Where you're storing your variable is important. You can use a LOCAL
variable, but then it's only visible to the method it's in. Otherwise add a
property to your button or your form to contain the variable.

*!* frmMyForm.cmdAddDiscount.Click()
THIS.Caption = "16%"

*!* Then, use one of the following three groups of code

*!* LOCAL variable
LOCAL lnDiscount
lnDiscount = .16

*!* Button property - nDiscount
THIS.nDiscount = .16

*!* Form property - nDiscount
THIS.Parent.nDiscount = .16

*!* Form property - nDiscount
ThisForm.nDiscount = .16

--
Cindy Winegarden  MCSD, Microsoft Visual FoxPro MVP

http://msdn.microsoft.com/vfoxpro  http://foxcentral.net


Quote:
> Can a command button be pressed and a variable be set to a
> number? I want to make a button that shows a discount 16
> percent as the button lable. If pressed I want to have a
> variable set to 16. Do I do this with an if statement? I
> tried and failed.
> I tried the If -(I do not know what the function of click
> is to tell it) then set variable =16. I tried the default
> of .F. and if command1 = .F. then vairable =16



Sat, 03 Sep 2005 22:42:48 GMT  
 buttons
A checkbox would be a more visible way of handling this. You set percent to
16 in the InteractiveChange event of the checkbox
 A checkbox can have the state values .T. or .F. or 1 or 0, depending on
what you assign in the Init event or set in the property sheet.

*Function Init
This.addproperty('percent', 0)
This.Value=0

*Function InteractiveChange
IF ThisValue = 1
   This.percent = 16
Else
  This.Percent=0
Endif

-Anders


Quote:
> Can a command button be pressed and a variable be set to a
> number? I want to make a button that shows a discount 16
> percent as the button lable. If pressed I want to have a
> variable set to 16. Do I do this with an if statement? I
> tried and failed.
> I tried the If -(I do not know what the function of click
> is to tell it) then set variable =16. I tried the default
> of .F. and if command1 = .F. then vairable =16

> Somehow I think I am doing this wrong.
> PS> I am an old basic programer that bought FoxPro to
> sharpen my skills (Which I find are non-existant in oop
> programing)
> Thanks,
> Mike



Sat, 03 Sep 2005 23:25:02 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Button, Button...

2. detecting buttons clicked on navigation buttons in a report print preview

3. Mac Push Buttons - Changing Colors When Buttons Pushed

4. Hot-Keys for invisible push buttons or bitmap push buttons

5. grids. with save button and new button

6. Help with save button and new button

7. help with save button and new button

8. Looking for Button/Bar Class similar to Buttons found in Delphi 3 and VC++ (floating mouse pointer over button raises it)

9. How do i from a button access another button in a cmdgroup?

10. a new question - using the delete button on the keyboard instead of a delete button on the form

11. Help referncing Buttons & Button Menu's on a VFP 6 OLE toolbar

12. How can i create IE 3.0 toolbar button

 

 
Powered by phpBB® Forum Software