Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference > Siebel VB Language Reference >
Val Function
This standard VB function returns the numeric value of the first number found in a string.
Syntax
Val(string)
Returns
The value of the first number in string. If no number is found, Val returns 0.
Usage
Spaces in the source string are ignored.
Example
This example tests the value of the variable profit and displays 0 for profit if it is a negative number. The subroutine uses Sgn to determine whether profit is positive, negative, or zero.
Sub Button_Click
Dim profit as Single
Dim expenses
Dim sales
expenses = 100000
sales = 20000
profit = Val(sales)-Val(expenses)
If Sgn(profit) = 1 then
`Yeah! We turned a profit!
ElseIf Sgn(profit) = 0 then
`Okay. We broke even.
Else
`Uh, oh. We lost money.
End If
End SubSee Also
CCur Function
CDbl Function
CInt Function
CLng Function
CSng Function
CStr Function
CVar Function
CVDate Function
Format Function
Str Function
Bookshelf Home | Contents | Index | Search | PDF |
Siebel VB Language Reference Published: 18 June 2003 |