[dba-VB] Converting the value in a field

Charlotte Foust cfoust at infostatsystems.com
Mon Dec 3 10:32:45 CST 2007


I understand that all the Ctype functions boil down to the same thing
under the hood and run about the same speed.  The benefit of CType is
that you can cast the object as just about anything, including custom
objects.  Don't recall being able to do that in VBA. ;}  You can also
use DirectCast if you are absolutely sure the object contains data and
is the right type.

Charlotte Foust 

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Saturday, December 01, 2007 11:18 PM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Converting the value in a field

And which type is faster?  CInt smells of VB6 compatibility code. 


John W. Colby
Colby Consulting
www.ColbyConsulting.com
-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Bobby Heid
Sent: Saturday, December 01, 2007 4:37 PM
To: dba-vb at databaseadvisors.com
Subject: Re: [dba-VB] Converting the value in a field

Hi John,

Yes, CInt will work.
As will: 
	mintNumOfRecsToExport = Ctype(!EDS_FileSize,Integer) and 
	mintNumOfRecsToExport = Convert.ToInt32(!EDS_FileSize)

Bobby

-----Original Message-----
From: dba-vb-bounces at databaseadvisors.com
[mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Saturday, December 01, 2007 12:04 PM
To: dba-vb at databaseadvisors.com; dba-sqlserver at databaseadvisors.com
Subject: [dba-VB] Converting the value in a field

I have lines of code like this:

mintNumOfRecsToExport = !EDS_FileSize

The compile complains because !EDS_FileSize is an object (a field) and
mintNumOfRecsToExport is an integer variable.  The error is:

Error	2	Option Strict On disallows implicit conversions from
'Object' to 'Integer'.	

There is no .Value property for the field object !EDS_FileSize.  Will
simply wrapping the object in CInt() fix the problem, or will I get an
integer pointer to the object?  

John W. Colby
Colby Consulting
www.ColbyConsulting.com 





More information about the dba-VB mailing list