Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


new to vb script want some basic help please

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,38761
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> new to vb script want some basic help please
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 new to vb script want some basic help please - 10/16/2006 7:44:16 PM   
  cw410005

 

Posts: 2
Score: 0
Joined: 10/4/2006
Status: offline
Sorry for such a newbie question!!

I have a form which gets a value on a page once this form is submitted I create a session variable on my next page


I then want to do some calculations on that number. Do I have to do anything like casting this string value to an integer? If so how do i do this


I thought this would work but doesnt


      

Could you advise how this is done please
 
 
Post #: 1
 
 RE: new to vb script want some basic help please - 10/27/2006 1:45:50 AM   
  LITTLERIC

 

Posts: 2
Score: 0
Joined: 10/26/2006
Status: offline
Sometimes you can store a form value in session and it will work, but as you suggested, casting is usually good before doing calc's.  With something like using the variable in a query string it doesn't matter because the query is a text string....but going the other way is tougher.  Reading a value from a form that comes back as 5 may not be the same on a compare when you match it with a database integer value of 5 ... until you do the casting.

That can be done with something like
yournum = CInt(Request.Form("thefield")) or yournum = CLng(Request.form("thefield"))

I have a function I use for doing that because sometimes you get burned with nulls, empty strings, etc.  Function checks for numeric and passes back 0 if it fails; otherwise does the cast into a Long Integer.  You'll probably find having that in some kind of core library would be helpful!


Good luck!

(in reply to cw410005)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> new to vb script want some basic help please Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts