Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combobox driving me crazy....
Message
 
 
To
04/04/2002 22:39:06
Ken Dibble
Southern Tier Independence Center
Binghamton, New York, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00641186
Message ID:
00641235
Views:
15
A few friendly advises. You're overusing macro substitution in your code which makes it slower, harder to read and maintain.
USED("&thetable")
* is the same as
USED(thetable)

IF &thefield = .T.
* is the same as
IF EVAL(thefield) 

REPLACE &thefield WITH .T.
* is the same as
REPLACE (thefield) WITH .T.
Also multiple related IF's could be replaced witd DO CASE ENDCASE
               DO CASE 
               CASE ISNULL(EVAL(thefield))
                    THIS.Value = ""
               CASE EVAL(thefield)
                    THIS.Value = "Yes"
               CASE NOT EVAL(thefield) 
                    THIS.Value = "No"
               ENDCASE
>>This shouldn't be so hard....
>>
>>What I'm trying to do is create a self-contained combobox class that will dropdown a Yes/No option, placing a corresponding .t. or .f. into a table.
>
>Hi Steve,
>
>Would this work? Put this on a form and set the value of YesNoSource to
>[some table].[some field]:
>
>
>DEFINE CLASS Yncombo AS Combobox
>     RowSourceType = 1
>     RowSource = "Yes,No"
>     Style = 2
>     FieldName = ""
>     TableName = ""
>     YesNoSource = ""
>
>     PROCEDURE Init
>          LOCAL dotspot, thetable, thefield
>
>          dotspot = AT(".",THIS.YesNoSource)
>
>          STORE LEFT(THIS.YesNoSource,(dotspot - 1)) TO THIS.TableName
>          STORE SUBSTR(THIS.YesNoSource,(dotspot + 1)) TO THIS.FieldName
>
>          STORE THIS.TableName TO thetable
>          STORE THIS.FieldName TO thefield
>
>          IF USED("&thetable")
>               IF &thefield = .T.
>                    THIS.Value = "Yes"
>               ENDIF
>
>               IF &thefield = .F.
>                    THIS.Value = "No"
>               ENDIF
>
>               IF ISNULL(&thefield)
>                    THIS.Value = ""
>               ENDIF
>          ELSE
>               THIS.Value = ""
>          ENDIF
>     ENDPROC
>
>     PROCEDURE Valid
>          LOCAL thetable, thefield
>
>          STORE THIS.TableName TO thetable
>          STORE THIS.FieldName TO thefield
>
>          IF NOT EMPTY(THIS.DisplayValue)
>               IF NOT USED("&thetable")
>                    MESSAGEBOX("The Yes/No Combobox data source is not open.")
>                    THIS.DisplayValue = ""
>                    RETURN
>               ENDIF
>          ENDIF
>
>          IF THIS.DisplayValue = "Yes"
>               REPLACE &thefield WITH .T.
>          ENDIF
>
>          IF THIS.DisplayValue = "No"
>               REPLACE &thefield WITH .F.
>          ENDIF
>
>          IF EMPTY(THIS.DisplayValue)
>               REPLACE &thefield WITH .F.
>          ENDIF
>     ENDPROC
>ENDDEFINE
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform