Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems re 'With...Endwith'
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00337018
Message ID:
00337234
Views:
10
>I am experiencing errors if I use a 'scan for' statement inside a with...endwith.
>
>
>with thisform
>   scan for .txtBox.value = 'xyz'
>      do something
>   endscan
>endwith
>
>
>The error I get is: 'Alias .txtbox.value is not found'. From within the debugger I can hold the cursor over this value and it has the correct value. The way to solve this is to add 'thisform' to '.txtbox.value'. But I was wondering if this is only happening to me or is this just the way it is. Also, is there any other commands I need to be concerned with this issue.
>

Paul, the notation you're using makes no sense - does .txtBox.Value contain the name of a field? if so, try:

LOCAL cFieldName
cFieldName = .txtbox.value
SCAN FOR (cFieldName) = 'xyz'

SCAN spins through a table, and the value in the textbox of a form is not going to change in the context of the scan - you want to check a field for a value presumably. If the value you're checking for is in the .txtbox.value, I'd recommend for simplicity and performance to copy the value to a memvar to eliminate the overhead and potential confusion in resolving the object reference each time the loop iterates, too.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform