logo
g Text Version
Auto
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Society & Culture
Sports
Travel & Leisure
TV & Movies

dailyclick
Bored? Games!
Postcards
Astrology
Take a Quiz
Rate My Photo

new
English Garden
Costuming
Charity
Women's Fashion
Pop Music


dailyclick
All times in EST

Low Carb: 8:00 PM

Full Schedule
g
g ASP Site
Editor Wanted
BellaOnline's ASP Editor

g

Cast - Reassigning Variable Type
Guest Author - Lisa Shea

In ASP you might occasionally see error messages about casting a variable or object. To cast a variable is to reassign its type.

In other languages, like C or C++, there are very specific commands used in order to change a variable. If you had PiValue = 3.141519, and you just wanted the integer (3) part of that number, you would recast PiValue as an integer.

ASP is far less picky about its variables. You really don't even have to define your variable types before you use them. If you have

PiValue = 3.141519

and you wanted to have a variable called PiShort with just the integer part, then you just say

PiShort = cInt(PiValue)

That's it, it takes the integer of PiValue and puts it into PiShort.

If you end up with casting errors, do a bunch of response.writes to see EXACTLY what every variable is set to along the way.

For example, if you start setting up a mail object -

Set objMail = Server.CreateObject("CDO.Message")

and then you try to turn objMail into an integer, that won't work :) So make sure that the variable you are starting with can actually be cast into the destination type variable.

This site needs an editor - click to learn more!

RSS | Related Articles | Previous Features | Site Map


Content copyright © 2008 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

Digg! g delicious Save to Del.icio.us

g


For FREE email updates, subscribe to the ASP Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor

g features
Best uses for RSS

RSS and its future.

Force Download Dialog box with ASP

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Driving Amount
Much more
Slightly more
Slightly less
Much less

g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2008 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor