Re: How to let the cursor stay implace?
- From: "Jeff" <Jeff@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 9 Jul 2005 05:53:01 -0700
Hi Bas,
Thank you very much for your reply. I’ll test your code. I didn’t use the
InputMask because with it the user has to key in exactly 7 digits. If the
input data has only 6 digits then the user has to add a “0” to the front
himself. What I try to do is if the user key in 6 digits, a “0” is added to
the front automatically.
I look through the codes you give me, I find that in the second part, that
is the part for testing digits only, you have put exit for after bRes=false.
But in the first part, that is the part for testing the length of the input
string, you didn’t put exit for. Why? I didn’t test your code yet.
Thank you very much once again.
--
Jeff
"Bas Cost Budde" 來函:
> I'd advise an input mask here. You can prevent entry of alpha
> characters, and restrict the length, in one go, using "9999999". See the
> Help on InputMask.
>
> If you don't want that, I came up with this:
>
> You can use the ValidationRule property of the control to call your
> function (set the property to =isValid() ). It should return True for
> valid data, False for invalid. You can even set the ValidationText
> property of the control from this function, as I have just tested.
> If the validation fails, the validationtext will be displayed. As a user
> I'd appreciate not to know that something is wrong, but how it should be
> corrected. So I propose this air coded validation function, watch line wrap:
>
> function isValid() as boolean
> dim i as integer'to scan the string
> dim bRes as boolean'will keep the function result
> dim cInvalid as string' we'll gather all messages here
> bRes = true'initially, until we discover an error
> with screen.activecontrol
> if len(.value)>7 then
> cInvalid="The entry is too long. You can enter up to 7 numerical digits."
> bres=false
> end if
> 'test if digits only
> for i=1 to len(.value)
> if instr("0123456789",mid(.value,i,1))>0 then
> cInvalid = cInvalid & " '" & mid(.value,i,1) & "' is not a valid
> character. Use only numerical digits."
> bRes=false
> exit for
> end if
> next
> if not bres then
> .validationtext = cInvalid
> end if
> end with
> isValid = bRes
> end function
>
> Nice little feature is that this will work for the active control; you
> don't have to explicitly put the control name in code.
>
> --
> Bas Cost Budde, Holland
> http://www.heuveltop.nl/BasCB/msac_index.html
> For human replies, replace the queue with a tea
>
>
.
- Follow-Ups:
- Re: How to let the cursor stay implace?
- From: Bas Cost Budde
- Re: How to let the cursor stay implace?
- References:
- How to let the cursor stay implace?
- From: Jeff
- Re: How to let the cursor stay implace?
- From: Bas Cost Budde
- How to let the cursor stay implace?
- Prev by Date: Backup
- Next by Date: Re: How to let the cursor stay implace?
- Previous by thread: Re: How to let the cursor stay implace?
- Next by thread: Re: How to let the cursor stay implace?
- Index(es):
Relevant Pages
|