Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using this.value within a control
Message
De
15/03/2000 00:09:39
 
 
À
14/03/2000 14:57:54
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00345497
Message ID:
00345685
Vues:
21
>Would you guys agree that it generally is a bad programming practice to use this.value within a control because it makes the code considerably harder to maintain.

Nope ...

>Using the actual variable or field to which the control is bound is much better.

... but less reusable, and possibly slower, and what if its a Valid() statement, the .Value of the control hasn't been applied to its controlsource yet, so its impossible to do anyhting with the controlsource.

Also, try this, the top box is the only one that will really work, because it uses .Value
oTest = createobject('ftest')
oTest.Show(1)
DEFINE CLASS ftest AS form


	Top = 0
	Left = 0
	Height = 124
	Width = 139
	DoCreate = .T.
	Caption = "Form2"
	cval1 = "Value1"
	cval2 = "VALUE2"
	cval3 = "vALUE3"
	Name = "csvsvalue"


	ADD OBJECT text1 AS textbox WITH ;
		ControlSource = "thisform.cVal1", ;
		Height = 23, ;
		Left = 18, ;
		Top = 12, ;
		Width = 100, ;
		Name = "Text1"


	ADD OBJECT text2 AS textbox WITH ;
		ControlSource = "thisform.cVal2", ;
		Height = 23, ;
		Left = 18, ;
		Top = 48, ;
		Width = 100, ;
		Name = "Text2"


	ADD OBJECT text3 AS textbox WITH ;
		ControlSource = "thisform.cVal3", ;
		Height = 23, ;
		Left = 18, ;
		Top = 84, ;
		Width = 100, ;
		Name = "Text3"


	PROCEDURE text1.InteractiveChange
		nSel = this.selstart
		this.value = proper(this.value)
		this.selstart = nSel
	ENDPROC


	PROCEDURE text2.InteractiveChange
		nSel = this.selstart
		this.value = proper(thisform.cval2)
		this.selstart = nSel
	ENDPROC


	PROCEDURE text3.InteractiveChange
		nSel = this.selstart
		thisform.cval3 = proper(thisform.cval3)
		this.selstart = nSel
		thisform.refresh()
	ENDPROC


ENDDEFINE
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform