Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

heres a stupid question... but an easy one :0)

Status
Not open for further replies.

redzombi19

Programmer
Jun 2, 2002
35
US
ok im still very new so please dont laugh,..... to hard.


ok the basid idea im trying to go with here is, i have a list of 5 cmd.buttons, and to start only 1 is visible.
when i click on one it launches a messagebox,when you choose yes, or no, the cmd.button disables itself and makes the next visible, it then deppending on the answer adds a 1 to either txt.box1 or txt.box2 on the form. which i have no problem with on the first cmd.button
but then in the next cmd.button i think i need to pass it a prameter of the variable i used in the first cmd.box,
and i cant for the life of me get this part correct!
i know its an easy thing to do but i have tried agin and agin and still no luck, so i figured id seek help before i went insane!!!
i have included below the code from cmd.box1, and cmd.box2, to help if my description was less than adequate
thanks guys. ;)
CMD.BOX1:-------------

lnquestion1 = MESSAGEBOX ("bla, bla, bla?",4+32,"yada yada yada")
lncorrect = 0 && the variables i need to pass
lnwrong = 0 && as parameters

IF lnquestion1 = 6 && yes
lncorrect = lncorrect + 1
ENDIF

IF lnquestion1 = 7 && no
lnwrong = lnwrong + 1
ENDIF

thisform.txtcorrect.value = ALLTRIM(STR(lncorrect))
thisform.txtincorrect.Value = ALLTRIM(STR(lnwrong))

this.Enabled = .f.
thisform.cmdquestion2.visible = .t.

--------------
SO FAR SO GOOD, HERES WHARE I SCREW UP.

CMD.BOX2:-------------

lnquestion2 = MESSAGEBOX("YADA, YADA, YADA?",4+32,"bla, bla, bla")

IF lnquestion2 = 6 && yes
lncorrect = lncorrect + 1 && the part whare i fail :(
ENDIF

IF lnquestion2 = 7 && no
lnwrong = lnwrong + 1 && here too ;(
ENDIF

thisform.txtcorrect.value = ALLTRIM(STR(lncorrect))
thisform.txtincorrect.Value = ALLTRIM(STR(lnwrong))

this.Enabled = .f.
thisform.cmdquestion3.visible = .t.
---------------
so there you go, i hope i gave enough info, i greatly appriciate all your help!


 
HI redzombi19,

Usually parameters are passed to a form when it is called like:

do form the_form with "Test"

The init event of the form would catch "Test". However, Test would be local to the init event so it could not be acknowledged anywhere else in the form. If "Test" were stored in a custom property of the form, it would be available anywhere in the form. You can create custom properties for a form by clicking on the [Form] option in the VFP menu bar while modifying a form. Then select [new property] and add the new property. Suppose you added a new property called the_value. Then the init event might look something like:


*************** Init Event *********************
PARAMETER passed_value
thisform.the_value = passed_value
***************eof******************************


After the above code had executed, the custom property the_value of thisform would contain Test. It could then be accessed anywhere within the form as follows:

new_value = thisform.the_value

This is the way you can make a variable public within a form.

Using this technique you could assign the value in the first button to a custom property. Then the second button could access the custom property to make the value avaible to it, etc

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
if the value of the textbox txtcorrect is M.incorrect you have changed it from a numeric value to a text value with these lines of code
thisform.txtcorrect.value = ALLTRIM(STR(lncorrect))
thisform.txtincorrect.Value = ALLTRIM(STR(lnwrong))

comment these lines and see what happens.

 
Hi RedZombi19,

One other thing that is often necessary when debugging code is to turn the debuger on and step through your code one line at a time while watching your variables. You can open the debug window in your button methods by issuing the following command:

set step on

Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top