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

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

new
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel
Southwest USA
Irish Culture


dailyclick
All times in EST

Full Schedule
g
g ASP Site

BellaOnline's ASP Editor

g

Cast - Reassigning Variable Type


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.
Add Cast+%2D+Reassigning+Variable+Type to Twitter Add Cast+%2D+Reassigning+Variable+Type to Facebook Add Cast+%2D+Reassigning+Variable+Type to MySpace Add Cast+%2D+Reassigning+Variable+Type to Del.icio.us Digg Cast+%2D+Reassigning+Variable+Type Add Cast+%2D+Reassigning+Variable+Type to Yahoo My Web Add Cast+%2D+Reassigning+Variable+Type to Google Bookmarks Add Cast+%2D+Reassigning+Variable+Type to Stumbleupon Add Cast+%2D+Reassigning+Variable+Type to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


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


Content copyright © 2014 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 Lisa Shea for details.

g


g features
Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


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


BellaOnline Editor