Re: How to let the cursor stay implace?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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
>
>
.



Relevant Pages

  • New LottoGenius version - comments please.
    ... limit an amount of numbers inside any decade. ... Final Digits: matching final digits (all digits count, ... control the low/high numbers ratio within a combination. ... Sums: range of sums (selected numbers within the combination ...
    (rec.gambling.lottery)
  • RE: erratic format result
    ... coding, which is same as I was usuing, as control source for the control on ... If zipcode is all 9 digits, and I use format 00000\-0000, then I get correct ... Format I showed it should work every time - like I said, ...
    (microsoft.public.access.modulesdaovba)
  • Re: How to let the cursor stay implace?
    ... You can prevent entry of alpha characters, and restrict the length, in one go, using "9999999". ... You can even set the ValidationText property of the control from this function, ... dim bRes as boolean'will keep the function result ...
    (microsoft.public.access.modulesdaovba)
  • Re: Driving 16 7-Segment Displays
    ... I very much like the idea of using an Interrupt Service Routine to ... i/o's to control the 7-segment displays.I ... > to multiplex 16 digits without using significant bandwidth. ... > current, not the multiplex frequency. ...
    (sci.electronics.design)
  • Re: concatenate and parse merged field with text
    ... in the replace with control. ... Doug Robbins - Word MVP ... last 7 digits of that number with a "W" in front. ... derive the web access ID, we need to concatenate a "W" with the last 7 ...
    (microsoft.public.word.mailmerge.fields)