#COMPILER PBWIN 9
#DIM ALL
' An example is worth a thousand words
'-------------------------------------------------------------------------------------------
'assuming --> {1234,Q145,Sales,Cost,$120.30} etc
'In an array that contains numbers and letters {ABC12} need to find only numbers{$1234.50}.
'It is what it claims this little routine
' Best idea welcome
' sorry for my bad English
'-------------------------------------------------------------------------------------------
'Esta funcion determina si puede usarse como numeral o no en una frase dada
'al momento que encuentra un elemento que no es numero o punto se sale
'dando funcion 0 , de lo contrario function -1
'no admite espacios daria Error no--> CHR$(32)
'-------------------------------------------------------------------------------------------
FUNCTION CaptSiEsNumOString(BYVAL Need_Num AS STRING) AS LONG
' This routine can be varied to specific needs
LOCAL char AS STRING
LOCAL y AS LONG
' del 0 al 9 CHR$(48,57)
FOR y = 1 TO LEN(Need_Num)
char$ = MID$(Need_Num,y,1) 'one by one each character
IF char => CHR$(48) AND char=<CHR$(57) OR char=CHR$(46) OR char =CHR$(36) THEN
FUNCTION = -1
ELSE
'It has elements that do not do Number
FUNCTION= 0
EXIT FUNCTION
END IF
NEXT y
END FUNCTION
'------------------------------------------------------------------------------
FUNCTION PBMAIN () AS LONG
LOCAL Result AS LONG
LOCAL Numeral AS STRING
'Example 1
numeral = "$459.60" '<-- we need this format
'Example 2
' numeral = "#120" 'or <-- this no
CaptSiEsNumOString numeral TO result
IF result <>0 THEN
REPLACE ".." WITH "." IN Numeral ' detectar 2 puntos dejar uno
MSGBOX numeral +" is what I need",64,FUNCNAME$
ELSE
MSGBOX numeral +" has elements that do not do my Number",64,FUNCNAME$
END IF
END FUNCTION
#DIM ALL
' An example is worth a thousand words
'-------------------------------------------------------------------------------------------
'assuming --> {1234,Q145,Sales,Cost,$120.30} etc
'In an array that contains numbers and letters {ABC12} need to find only numbers{$1234.50}.
'It is what it claims this little routine
' Best idea welcome
' sorry for my bad English
'-------------------------------------------------------------------------------------------
'Esta funcion determina si puede usarse como numeral o no en una frase dada
'al momento que encuentra un elemento que no es numero o punto se sale
'dando funcion 0 , de lo contrario function -1
'no admite espacios daria Error no--> CHR$(32)
'-------------------------------------------------------------------------------------------
FUNCTION CaptSiEsNumOString(BYVAL Need_Num AS STRING) AS LONG
' This routine can be varied to specific needs
LOCAL char AS STRING
LOCAL y AS LONG
' del 0 al 9 CHR$(48,57)
FOR y = 1 TO LEN(Need_Num)
char$ = MID$(Need_Num,y,1) 'one by one each character
IF char => CHR$(48) AND char=<CHR$(57) OR char=CHR$(46) OR char =CHR$(36) THEN
FUNCTION = -1
ELSE
'It has elements that do not do Number
FUNCTION= 0
EXIT FUNCTION
END IF
NEXT y
END FUNCTION
'------------------------------------------------------------------------------
FUNCTION PBMAIN () AS LONG
LOCAL Result AS LONG
LOCAL Numeral AS STRING
'Example 1
numeral = "$459.60" '<-- we need this format
'Example 2
' numeral = "#120" 'or <-- this no
CaptSiEsNumOString numeral TO result
IF result <>0 THEN
REPLACE ".." WITH "." IN Numeral ' detectar 2 puntos dejar uno
MSGBOX numeral +" is what I need",64,FUNCNAME$
ELSE
MSGBOX numeral +" has elements that do not do my Number",64,FUNCNAME$
END IF
END FUNCTION
Comment