Wiki source for KeyPgVallng


Show raw source

{{fbdoc item="title" value="VALLNG"}}----
Converts a string to a 64bit integer

{{fbdoc item="syntax"}}##
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Vallng** ( [[KeyPgByref|byref]] //strnum// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgString|string]] ) [[KeyPgAs|as]] [[KeyPgLongint|longint]]
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Vallng** ( [[KeyPgByref|byref]] //strnum// [[KeyPgAs|as]] [[KeyPgConstQualifier|const]] [[KeyPgWstring|wstring]] ) [[KeyPgAs|as]] [[KeyPgLongint|longint]]
##
{{fbdoc item="usage"}}##
//result// = **Vallng** ( //strnum// )
##
{{fbdoc item="param"}}
##//strnum//##
the string to convert

{{fbdoc item="ret"}}
Returns a ##[[KeyPgLongint|longint]]## of the converted string

If the first character of the string is invalid, ##**Vallng**## will return ##0##.

{{fbdoc item="desc"}}
For example, ##**Vallng**("10")## will return ##10##, and ##**Vallng**("10.60")## will return ##10## as well. The function parses the string from the left, skipping any white space, and returns the longest number it can read, stopping at the first non-suitable character it finds. Any non-numeric characters, including decimal points and exponent specifiers, are considered non-suitable, for example, ##**Vallng**("23.1E+6")## will just return ##23##.

##**Vallng**## can be used to convert integer numbers in [[KeyPgBin|binary]] / [[KeyPgOct|octal]] / [[KeyPgHex|hexadecimal]] format, if they have the relevant identifier (##"&B"## / ##"&O"## / ##"&H"##) prefixed, for example: ##**Vallng**("&HFF")## returns ##255##.

If you want to convert a number into string format, use the ##[[KeyPgStr|Str]]## function.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/strings/vallng.bas"}}%%(freebasic)
dim a as string, b as longint
a = "20xa211"
b = vallng(a)
print a, b
%%

%%
20xa211 20
%%


{{fbdoc item="lang"}}
- Not available in the //[[CompilerOptlang|-lang qb]]// dialect unless referenced with the alias ##**""__Vallng""**##.

{{fbdoc item="diff"}}
- New to ""FreeBASIC""

{{fbdoc item="see"}}
- ##[[KeyPgClngint|Clngint]]##
- ##[[KeyPgVal|Val]]##
- ##[[KeyPgValint|Valint]]##
- ##[[KeyPgValulng|Valulng]]##
- ##[[KeyPgStr|Str]]##
- ##[[KeyPgChr|Chr]]##
- ##[[KeyPgAsc|Asc]]##

{{fbdoc item="back" value="CatPgCasting|Converting Data Types"}}{{fbdoc item="back" value="CatPgString|String Functions"}}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode