Author |
Topic  |
|
gtbird
Starting Member
25 Posts |
Posted - 02 July 2001 : 14:03:56
|
I'm slowly learning some ASP. I've been reading Begining Active Server Pages. In any event, I have a quick question. When you use typenames, are you basically just forcing a variable to become a certain type? If so, what's the sense in designing the language to use two variables where you should get away with only using 1? Thanks ahead of time.
|
|
Kat
Advanced Member
    
United Kingdom
3065 Posts |
Posted - 03 July 2001 : 04:20:11
|
I have not actually heard of typenames, but with ASP 2.0 and below, you can't force a variable to become a particular type. They are all as Variant type by default.
If anyone else can explain typename I would be interested to know what it is.
KatsKorner
|
 |
|
aspdesigner
Junior Member
 
165 Posts |
Posted - 03 July 2001 : 05:03:50
|
TypeName(var) is a Visual Basic function that will return a string which identifies the "type" (i.e. - Byte, String, Integer, etc.) of the variable passed to it.
|
 |
|
gtbird
Starting Member
25 Posts |
Posted - 03 July 2001 : 13:25:59
|
Ok, I think I understand. It's nothing critical, just something to help you out if you need it? Thanks!
|
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 03 July 2001 : 13:34:05
|
In VBScript, variables are 'variants' with a sub-type like integer, long, string, etc. The typename function returns the name of the variable's sub-type.
Visit msdn.microsoft.com/scripting and navigate to the VBScript documentation for more information on the use of VBS in your asp pages.
I didn't understand what you meant by using two variables.
====== Doug G ====== |
 |
|
gtbird
Starting Member
25 Posts |
Posted - 03 July 2001 : 16:08:11
|
In the book I'm reading, they have a bit of code:
LengthOfAPieceOFString = 5 WhatTypeOfVar = TypeName(LengthOfAPieceOfString)
I wasn't sure what exactly that did.
That's where I got the two variables.
Edited by - gtbird on 03 July 2001 16:08:40 |
 |
|
Doug G
Support Moderator
    
USA
6493 Posts |
Posted - 03 July 2001 : 18:16:40
|
quote: LengthOfAPieceOFString = 5 WhatTypeOfVar = TypeName(LengthOfAPieceOfString)
If you added response.write "Variable Type is: " & WhatTypeOfVar the result in your page should be Variable Type is: Integer. The snip of code first assigns the integer value 5 to a variable named LengthOfAPieceOfString (gotta love the variable naming convention!). The next line assigns the output of the Typename function to another variable WhatTypeOfVar.
The typename function is one of the many functions built in to VB Script.
HTH
====== Doug G ====== |
 |
|
gtbird
Starting Member
25 Posts |
Posted - 06 July 2001 : 09:11:45
|
Thanks!
|
 |
|
|
Topic  |
|