Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IsNumeric - VFP analogue?
Message
 
 
À
26/12/1999 23:57:33
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00307922
Message ID:
00308764
Vues:
32
Albert,

Thanks for this code. I'm afraid, it's too complicated for me. I'll try it anyway.

Meanwhile, if you read the whole thread (more than 50 messages, though), you'd see, that my attitude was changed and I'm willing to use another control for validation. At least, I'll do it in a fiture.

Within my current application I already solved validation problem, not very sufficient, but at least, it works fine and fast. I'm using George's function IsNumeric. (Dragan advised something like StrFilter from FoxTools, I have to take a look, but IsNumeric function satisfied me)

Thanks again.


>Here is an example with an editbox. I'll leave it up to you to solve the problem of the caret (text insertion point indicator) shifting one character to the right for every line after line 1.
>
>
>oForm = createobject("TestForm")
>oForm.Visible = .t.
>read events
>
>define class TestForm as form
>  add object edtValidated as ValidatedEditbox
>  procedure QueryUnload
>    clear events
>  endproc
>enddefine
>
>define class ZipValidator as custom
>
>  DigitCount = 5
>	
>  function init
>    lparameters tnDigitCount
>		
>    if vartype( tnDigitCount ) = 'N'
>      this.DigitCount = tnDigitCount
>    endif
>  endfunc
>
>  function ValidateString
>    lparameters tcString
>		
>    local array laString[1]
>    local i, lnLineCount
>		
>    if vartype( tcString ) = 'C'
>      lnLineCount = alines(laString, tcString, .t.)
>      tcString = ""
>      for i = 1 to lnLineCount
>        if !empty(laString[i])
>          laString[i] = transform(int(val(laString[i])))
>          * padr() is used because you are formatting ZIP Codes
>          laString[i] = padr(laString[i], this.DigitCount, '0')
>          tcString = tcString + laString[i] + chr(13)
>        endif
>      endfor
>    endif
>
>    return tcString
>
>  endfunc
>
>enddefine
>
>define class ValidatedEditbox as editbox
>
>  * default validator, for some reason createobject() won't work here
>  Validator = null
>	
>  function init
>    lparameters toValidator
>		
>    * we are using deligation for the validator
>    if vartype( toValidator ) = 'O'
>      this.Validator = toValidator
>    else
>      this.Validator = createobject("ZipValidator")
>    endif
>  endfunc
>
>  procedure InteractiveChange
>    this.Value = this.Validator.ValidateString(this.Value)
>  endproc
>	
>enddefine
>
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform