oForm=createobject('myForm') oForm.Show Read events Define class myForm as form Add object txt1 as myTextbox with left = 10, top= 10, name= 'txt1', ; value = 0, forecolor=rgb(192,192,192) Add object txt2 as myTextbox with left = 10, top= 30, name= 'txt2', ; value='text',forecolor=rgb(92,255,255) Add object txt3 as myTextbox with left = 10, top= 50, name= 'txt3', ; value = datetime() Add object txt4 as myTextbox with left = 10, top= 70, name= 'txt4', ; controlsource='myTest.f1' Add object txt5 as myTextbox with left = 10, top= 90, name= 'txt5', ; controlsource='myTest.f2' Add object txt6 as myTextbox with left = 10, top=110, name= 'txt6', ; controlsource='myTest.f3' Add object comb as commandbutton with left=200, autosize=.t., ; caption = 'txt2 to num, txt1 to char' Add object comb2 as commandbutton with left=200, top= 50, autosize=.t., ; caption = 'txt1 to num, txt2 to char' Procedure load Create cursor mytest (f1 i, f2 c(10), f3 d) Insert into mytest values (1,'hello',date()) Endproc Procedure queryunload Clear events Endproc Procedure comb.click With thisform .txt1.value = 'hello' .txt1.setcolor() .txt2.value = 2 .txt2.setcolor() Endwith Endproc Procedure comb2.click With thisform .txt1.value = 1 .txt1.setcolor() .txt2.value = 'hello' .txt2.setcolor() Endwith Endproc Enddefine Define class myTextbox as textbox Procedure Init This.setcolor() Endproc Procedure lostfocus This.setcolor() Endproc Procedure setcolor With this If type('.value')='N' Do case Case .value = 1 lnColor = rgb(255,0,0) Case .value = 2 lnColor = rgb(0,255,0) Case .value = 3 lnColor = rgb(0,0,255) Otherwise lnColor = rgb(255,0,255) Endcase .Forecolor = lnColor Else .ResetToDefault('Forecolor') Endif Endwith Endproc EnddefineCetin