New topic: 

This got me surprised

<http://forums.realsoftware.com/viewtopic.php?t=43908>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        wex-alpha          Post subject: This got me surprisedPosted: 
Mon May 07, 2012 8:04 am                         
Joined: Mon Jul 30, 2007 5:03 am
Posts: 90
Location: Sarajevo - Bosnia                I was doing number/string 
conversions and this surprised me:

dim a as string = "HEY THERE"
dim b as Integer = val(a)

B is now ZERO // was expecting error here!!!

dim a as string = "25 HEY THERE"
dim b as Integer = val(a)

B is now 25 // was definitely expecting error here


It seems that compiler is doing the heavy work instead of me, such as trying 
and then converting. Is this working as intended?   
                             Top                Paul Lefebvre          Post 
subject: Re: This got me surprisedPosted: Mon May 07, 2012 8:32 am              
         Site Admin                
Joined: Fri Sep 30, 2005 9:35 am
Posts: 722
Location: South Portland, Maine                Yes, this is definitely working 
as intended.

http://docs.realsoftware.com/index.php/Val      
_________________
Paul Lefebvre
Developer Evangelist
Real Software, Inc.

Real World 2012, The Real Studio event of the year!  
                             Top                DaveS          Post subject: 
Re: This got me surprisedPosted: Mon May 07, 2012 9:13 am                       
          
Joined: Sun Aug 05, 2007 10:46 am
Posts: 3660
Location: San Diego, CA                If you WANT those to be errors... .check 
the string first using the ISNUMERIC function      
_________________
Dave Sisemore
MacPro, OSX 10.7.3 RB2011r3
Note : I am not  interested in any solutions that involve custom Plug-ins of 
any kind  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to