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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update textbox value 2

Status
Not open for further replies.

DPaul1994

Programmer
Mar 9, 2015
46
RO
Hi. Let's just say I have a checkbox named Text1 and a checkbox named Text2. I would like to do this: if Text1 is empty, Text2 = 1 else Text2 = Text1
(thisform.Text1.Value, thisform.Text2.Value)
How cna I do this?
I tried like this:

Code:
if empty(thisform.Text1.Value)
thisform.Text2.value = 1
else
thisform.Text2.value = thisform.Text1.Value
endif

But it doesn't work. When I run the program, of course that Text2 has value 1. But when I introduce a value (numeric) in Text1, I want like Text2 = Text1 (value)
 
First, if you are using Checkboxes, I would never name them "TEXT" anything.
Mostly because it's value can never be TEXT/u] (with the exception of the Caption). That only leads to confusion.
Personally I'd name it something like: chkBox1, chkPrintForm, chkReadFiles, etc.

Next where you put your code depends on when you want it to execute.

I tried like this: But you did not say where you put the code.

If you want it to be initially set upon initially launching the Form, then put the code into the Form's Init Method
If you want the code to execute when a user makes a change to the value of chkBox1, then put it into that object's Valid method.

Good Luck,
JRB-Bldr


 
Place your code in text.interactivechange() event

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Is not checkbox, is textbox, I wrong, i reply with that :)
I will try vgulielmus
 
You entered your change from Checkboxes to Textboxes just before I hit Submit.

Regardless, what I recommended is basically the same.

If you want it to be initially set upon initially launching the Form, then put the code into the Form's Init Method
Init Method....​
IF EMPTY(ThisForm.Textbox1.Value)
ThisForm.Textbox2.Value = 1​
ELSE
mValue = ThisForm.Textbox1.Value​
ThisForm.Textbox2.Value = mValue​
ENDIF​

If you want the code to execute when a user makes a change to the value of chkBox1, then put it into that object's Valid method.
Textbox1.Valid Method (basically the same)...​
IF EMPTY(ThisForm.Textbox1.Value)
ThisForm.Textbox2.Value = 1​
ELSE
mValue = ThisForm.Textbox1.Value​
ThisForm.Textbox2.Value = mValue​
ENDIF
ThisForm.Textbox2.Refresh​


Good Luck,
JRB-Bldr

 
Valid method does not work, either by changing interactive.
 
Text2 value is not changing when I insert value in Text1 :(
 
It's working in click method, but I want it in a method like live update or I don't know..
 
Please excuse my typo
Place your code in text1.interactivechange() event

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Aaa. I don't really know how to use that, I thought that I have to double click on Text1 and select from list InteractiveChange and then insert the code..How do I have to use that?
 
DPaul1994 said:
double click on Text1 and select from list InteractiveChange and then insert the code
That's exactly what I mean

Should behave like this
Code:
PUBLIC ofrm
ofrm = CREATEOBJECT("MyForm")
ofrm.show()

DEFINE CLASS MyForm as Form
	ADD OBJECT text1 as textbox WITH value = 0
	ADD OBJECT text2 as textbox WITH top = 50, value = 1
	PROCEDURE text1.interactivechange
		IF EMPTY(thisform.Text1.Value)
			thisform.Text2.value = 1
		ELSE
			thisform.Text2.value = thisform.Text1.Value
		ENDIF 
	ENDPROC
ENDDEFINE

Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
If it still doesn't get visible, refresh the form: Thisform.Refresh()

Bye, Olaf.
 
And I should do that in Valid method or in InteractiveChanges ?
 
Hint: The names of the event have meanings.

Valid only runs, if you tab away from a control and is for checking the validity of the value. It's not at all helpful when you want each interactive change of the value to reflect somewhere else on the form.
So what event do you use, if you want to react to interactive changes?

Bye, Olaf.


 
No event unfortunately..code for Click event is this:
Code:
USE meciuri
LOCATE FOR thisform.Text1.Value = idm
IF FOUND()
IF thisform.Text6.Value = "1" OR thisform.Text6.Value = "X" OR thisform.Text6.Value = "2" OR thisform.Text6.Value = "1X" OR thisform.Text6.Value = "X2" OR thisform.Text6.Value = "12"
IF thisform.Text6.Value = meciuri.p1 THEN  
cota1 = meciuri.cp1
endif
IF thisform.Text6.Value = meciuri.p2 THEN 
cota1 = meciuri.cp2
endif
IF thisform.Text6.Value = meciuri.p3 THEN 
cota1 = meciuri.cp3
endif
IF thisform.Text6.Value = meciuri.p4 THEN 
cota1 = meciuri.cp4
endif
IF thisform.Text6.Value = meciuri.p5 THEN 
cota1 = meciuri.cp5
endif
IF thisform.Text6.Value = meciuri.p6 THEN 
cota1 = meciuri.cp6
ENDIF
ELSE
MESSAGEBOX("Text6 value can be only: 1,1X,2,X2,12 !!!")
RETURN
ENDIF
ELSE
MESSAGEBOX("Value doesn't exist!")
RETURN
ENDIF 
thisform.Text15.Value = cota1

'Text15' is the textbox that I have to replace with 'cota1' value which depands on another textbox value.
 
But I want like Text15 value to change right after inserting value in Text6, without any click on Text15 textbox.
 
Then place the desired code in the InteractiveChange event of Text6.
- double click Text6
- select (procedure) InteractiveChange
and type something appropriate (like this piece of code) :
Code:
* Object: Text6
* Procedure: InteractiveChange
IF EMPTY(thisform.Text6.Value)
	thisform.Text15.value = 1
ELSE
	thisform.Text15.value = thisform.Text6.Value
ENDIF

P.S. I saw "meciuri", "cota"... Are you a Romanian or a Moldavian student (1994 I presume is your birth year)?


Respectfully,
Vilhelm-Ion Praisach
Resita, Romania
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top