Is the list working, had nothing since sat? --- Andy Hayman Kensington Computers Internet & Computers Systems Consultant Web <http://www.ken.co.uk> Email <mailto:[EMAIL PROTECTED]> Telephone 020 7835 1282 Fax: 020 7373 6900
Disclaimer This e-mail is confidential and intended solely for the use of the individual to whom it is addressed. Any views or opinions presented are solely those of the author and do not represent those of Kensington Computers. If you are not the intended recipient, be advised that you have received this mail in error and that any use, dissemination, forwarding, printing or copying of this e-mail is strictly prohibited. > -----Original Message----- > From: Michael Elfial [mailto:[EMAIL PROTECTED]] > Sent: 10 August 2002 14:54 > To: ActiveServerPages > Subject: RE: Turning a string to an number > > > Hi, > > I'll try to point you some more info: > > First consider these functions in VBS/VB > CInt - short integer (2 bytes signed integer) - VT_I2 > Clng - Long integere (4 bytes signed integer) - VT_I4 > CCur - Currency (8 bytes signed integer in fact, but shown as > currency in > practice) - VT_CY > CSng - 4 byte floating point - VT_R4 > CDbl - 8 bytes floating point - VT_R8 > > The VT_XX constants are the type constants for the so called > VARIANT type in automation Win32 COM APIs. It supports more > types and many of them are directly supported by VBS See the > VarType function and the corresponding constants - they are > numerically equivalent to these VT_X constants (only the > names are different). In other words VBS keeps everything in > VARIANT - any variable can hold any kind of value supported > by VARIANTs but you have ability (through the above functions > - not all are listed here) to specify the contents of the > variant. Most ActiveX will convert the input parameters (and > read properties) to the type they need, but if they know what > they need! Many ActiveX are able to work with different > values and produce different results. One example you meet > every day are the collections - if you put numeric index this > is the index of an item, if you put a string this is the name > of the item. Therefore the strict conversion is useful (if > you have time to deal with these details) always. > > Checking functions: > IsNumeric - will return true if the passed parameter is a > variant of numeric type or can be converted to a numeric type > - see this: v = "1" IsNumeric will return True v = 1 > IsNumeric will return True While VarType will return vbString > in the first case and vbInteger in the second. Thus you can > check if the conversion is possible with IsNumeric and "what > I have currently" with VarType. Of course in ASP you will > have mostly string to numeric and reverse conversions, but > using 3-D party components may lead to something else. > > ADO > You have a Filed.Type property but it returns ADO specific > constants, not very convenient. In many cases you can do > something better if you need to check what is the type of a > field. Check the type of the field value - like this: > VarType(rst("field").Value) > The .Value is important - if omited you will always receive > vbObject - e.g. the ADO field is object and Value is its > default property implicitly resolved in most cases. I > understood you do not have this problem right now but if you > need to learn about the recordset's values dynamically and > you want to avoid using ADO specific constants and methods > this will help in many cases. > > My own suggestion: > rst("FieldName").Value = variable > variable = rst("FieldName").Value > > Most people prefer to write: > rst("FieldName") = variable > variable = rst("FieldName") > > Why? First gets the variable value the second records a > reference to the Field object. In the first case variable > will be valid always in the second it will depend on the > recordset and if it is closed you will not be able to read > the value. This is similar to the GetRows - it copies the > values from teh recordset - i.e. independent copy, the > recordset can be closed. > > Why I am talking about this? Because I want of course ;) heh > , but also because I am working with many external components > - mine, others .... And with them this could be very > important - passing a reference to an ADO Field to another > object may be inconenient and sometimes dangerous. In your > case you want to get a variable from the Request - suppose this: > > rst("f") = Request("V") > This line depends on resulution of the default properties and > is equal to: > > rst.Field("f").Value = Request.Item("v").Item() > ADO bahaves this way, but who knows what is the bahavior of > some 3-Dparty component ? > Then: > obj.property = CLng(Request("V")) > will guarantee you are passing a long integer to the > component's property. > > And so on ... > Excuse me for the long story but I just corrected one's ASP > causing these problems :) > > Michael > > > > > > -----Original Message----- > From: Andy Hayman [mailto:[EMAIL PROTECTED]] > Sent: Friday, August 09, 2002 7:05 PM > To: ActiveServerPages > Subject: Turning a string to an number > > > I did know but I cant find it, how do you turn a string into a number > > Basicly I have a number in a drop down box which is being > treated as a Number but I need to put it in a numberic field!!! > > > --- > Andy Hayman > Kensington Computers > Internet & Computers Systems Consultant > Web <http://www.ken.co.uk> > Email <mailto:[EMAIL PROTECTED]> > Telephone 020 7835 1282 > Fax: 020 7373 6900 > > Disclaimer > This e-mail is confidential and intended solely for the use > of the individual to whom it is addressed. Any views or > opinions presented are solely those of the author and do not > represent those of Kensington Computers. If you are not the > intended recipient, be advised that you have received this > mail in error and that any use, dissemination, forwarding, > printing or copying of this e-mail is strictly prohibited. > > > > --- > You are currently subscribed to activeserverpages as: > [EMAIL PROTECTED] To unsubscribe send a blank email to > %%email.unsub%% > > > --- > You are currently subscribed to activeserverpages as: > [EMAIL PROTECTED] To unsubscribe send a blank email to > %%email.unsub%% > --- You are currently subscribed to activeserverpages as: [email protected] To unsubscribe send a blank email to [EMAIL PROTECTED]
