Thread: VAL keyword
View Single Post
  #11 (permalink)  
Old 12-13-2009, 06:55 AM
taximania's Avatar
taximania taximania is offline
Basic4ppc Expert
 
Join Date: May 2007
Location: Derbyshire. UK
Posts: 592
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Here's a starter for you. If you haven't done it already.

Code:
Sub VAL(s)
temp = 
""
temp2=
0
flag = 
0
If StrLength(s) = 0 Then
    
Return 0
Else
    len = StrLength(s)
    
For a = 0 To len -1
        
If IsNumber(StrAt(s,a)) Then
            temp = temp & StrAt(s,a)
        
Else
            
If StrAt(s,a) = "." Then
                
If flag = 0 Then
                    flag = 
1
                    temp = temp & 
"."
                
End If
            
End If
        
End If
    
Next
    
If temp = "" OR temp = "." Then
        
Return 0
    
Else
        temp2 = temp2 + temp
        
Return temp2
    
End If
End If
End Sub
Returns 0 for no number found.
The first '.' found is treat as a decimal point. All others are ignored.
Trims excessive leading and trailing '0's.
__________________
.
.
.
Don't ask, I'm fine, honest. !!
.
.
.
Just a little crazy at times



O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80


http://www.taximania.co.uk
Reply With Quote