[quoted text clipped - 23 lines]
Hi Ian
I hope I made the following clear:
The easiest and most technically correct way to do what you wish to do is to
use variables of different types.
If you were asked to design a database for contacts which had a uniqueID, a
first name, a last name, a date of birth and a height in metres then it
would be pretty unusual to have each field in the table as text and then try
and work out what sort of text it is. Normally, the ID would be a long
integer, the names would be text, the dob a date and the height perhaps a
single.
When I read the values from the table, I read them into appropriate
variables:
e.g.
strFirstName=MyRecordset.Fields("FirstName")
lngContactID=MyRecordset.Fields("ContactID")
If I then needed to find out what datatype these variables were I could use:
?TypeName(strFirstName) which returns "String"
?TypeName(lngContactID) which returns "Long"
Alternatively
?VarType(strFirstName) which returns the constant vbString=8
?VarType(lngContactID) which returns the constant vbLong=3
THIS REALLY IS THE WAY TO GO. However, imagine you have no choice and for
some reason you are passed a series of strings and have to work out what
datatype they are, then what could you do? Well I would not use any of the
built-in functions because they accept too wide a range of values. If I
wanted to know if a string represented a positive long integer then I would
want to know that each character in the string was 0-9 so I might ask
If strValue Like String$(Len(strValue), "#")
or for a date in international format, I could look for:
If strValue Like "####-##-## ##:##:##" Then
Finally, as a double check explicitly convert to the datatype to force an
error if it can't be converted.
THE PROBLEM YOU STILL HAVE is how do you know if 562 is supposed to be text,
an integer, a long integer - or how can you distinguish between the literal
text value of "True" and the boolean datatype. The truth is you cannot.