Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 typename
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

gtbird
Starting Member

25 Posts

Posted - 02 July 2001 :  14:03:56  Show Profile
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  Show Profile  Visit Kat's Homepage
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
Go to Top of Page

aspdesigner
Junior Member

165 Posts

Posted - 03 July 2001 :  05:03:50  Show Profile
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.


Go to Top of Page

gtbird
Starting Member

25 Posts

Posted - 03 July 2001 :  13:25:59  Show Profile
Ok, I think I understand. It's nothing critical, just something to help you out if you need it? Thanks!

Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 03 July 2001 :  13:34:05  Show Profile
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
======
Go to Top of Page

gtbird
Starting Member

25 Posts

Posted - 03 July 2001 :  16:08:11  Show Profile
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
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 03 July 2001 :  18:16:40  Show Profile
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
======
Go to Top of Page

gtbird
Starting Member

25 Posts

Posted - 06 July 2001 :  09:11:45  Show Profile
Thanks!

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.27 seconds. Powered By: Snitz Forums 2000 Version 3.4.07