Article View: borland.public.delphi.language.objectpascal
Article #155help with variant type - null/unknown type?
From: BBaley
Date: Tue, 28 Mar 2006 13:00
Date: Tue, 28 Mar 2006 13:00
69 lines
3161 bytes
3161 bytes
Hi,
I am having difficulty with determining the variant type passed (from a
program / procedure I did not code - I am working on a DLL that is
called from this app)
I have tried to go through the known vartypes but the variant seems to
match none of them??
Normally I am trying to determine the cause of an EConverError: not a
valid floating point value (during debugging - the try-except handles
during execution normally)
Am I missing something (below) or is there a better way to do this? I
always come up with NO resulting vartype?
----------------------------------------------------------------
function VarToInt(V: Variant) : integer;
var
es : string;
begin
try
if not(VarIsNull(V) or VarIsEmpty(v)) then
begin
If ( VarType(v) IN[varByte, varSmallInt, varShortInt,
varInteger, varWord, varLongWord, varInt64]) then
begin
result := Integer(V);
end;
end
else
begin
If ( VarType(v) IN[varSingle, varDouble, varCurrency]) then
begin
result := Round(v)
end
else
begin
{$IFDEF Include_DBG_Display}
ShowMessage('wrong type: expected integer');
case VarType(v) of
varEmpty : es := 'Empty';
varVariant : es := 'Variant';
varUnknown : es := 'Unknown';
varAny : es := 'varAny';
varString : es := 'String';
varOLEStr : es := 'OLEStr';
varStrArg : es := 'StrArg';
varDate : es := 'Date';
varBoolean : es := 'Boolean';
varError : es := 'varError';
varDispatch : es := 'Dispatch';
end;
Showmessage('var = ' + es);
{$ENDIF}
result := 0;
end;
end;
except
on Exception do
result := 0;
end; {- try/except -}
Technical Details
Message-ID:
<1143550859.522193.27890@u72g2000cwu.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!u72g2000cwu.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 109d30,7461644458c21eae,start X-Google-Attributes: gid109d30,public X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!u72g2000cwu.googlegroups.com!not-for-mail From: "BBaley" <brian_baley@poptal.com> Newsgroups: borland.public.delphi.language.objectpascal Subject: help with variant type - null/unknown type? Date: 28 Mar 2006 05:00:59 -0800 Organization: http://groups.google.com Lines: 70 Message-ID: <1143550859.522193.27890@u72g2000cwu.googlegroups.com> NNTP-Posting-Host: 206.163.85.82 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1143550865 5722 127.0.0.1 (28 Mar 2006 13:01:05 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 28 Mar 2006 13:01:05 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.0 firewall.poptal.com:80 (squid/2.5.STABLE10) Complaints-To: groups-abuse@google.com Injection-Info: u72g2000cwu.googlegroups.com; posting-host=206.163.85.82; posting-account=noMGsw0AAAAfMFLA-_BC25ydO9Zt68gk