Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Numeric or string ??
Message
De
09/02/2005 22:30:18
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
00985094
Message ID:
00985417
Vues:
77
This message has been marked as the solution to the initial question of the thread.
>No, I'm not. I did some testing:
>
>when I put in a date or numeric value, type(textbox.value) returns the correct type, but when I put in characters it returns 'U', which is not a problem (as you already pointed out). Now I know for sure that when I get the 'U' returned, the textbox value is character.
>
>Thanks a lot for your help !


I don't know if this is what you are looking for or not but it might help.
?WhatTypeIsIt(textbox.value)

?Convert2Whatever(textbox.value)


function WhatTypeIsIt
LPARAMETERS m.lcVar2check

IF TYPE("m.lcVar2check") = "C"
	DO CASE
		CASE !EMPTY(CTOD(m.lcVar2check))
			RETURN "D"
		CASE !EMPTY(CTOT(m.lcVar2check))
			RETURN "T"
		CASE INLIST(UPPER(m.lcVar2check),"T","F","TRUE","FALSE",".T.",".F.")
			RETURN "L"
		CASE TYPE(m.lcVar2check) = "N"
			RETURN "N"
		OTHERWISE
			RETURN "C"
	ENDCASE
ELSE
    RETURN TYPE("m.lcVar2check")
ENDIF


function Convert2Whatever
LPARAMETERS m.lcVar2check

IF TYPE("m.lcVar2check") = "C"
	DO CASE
		CASE !EMPTY(CTOD(m.lcVar2check))
			RETURN CTOD(m.lcVar2check)
		CASE !EMPTY(CTOT(m.lcVar2check))
			RETURN CTOT(m.lcVar2check)
		CASE INLIST(UPPER(m.lcVar2check),"T","F","TRUE","FALSE",".T.",".F.")
			RETURN iif(INLIST(UPPER(m.lcVar2check),"T","TRUE",".T."),.T., .f.)
		CASE TYPE(m.lcVar2check) = "N"
			RETURN val(m.lcVar2check)
		OTHERWISE
			RETURN m.lcVar2check
	ENDCASE
ELSE
	return m.lcVar2check
ENDIF
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform