AYUDA EN LÍNEA
 WINDEVWEBDEV Y WINDEV MOBILE

Este contenido se ha traducido automáticamente.  Haga clic aquí  para ver la versión en inglés.
Ayuda / WLanguage / Funciones WLanguage / Funciones estándar / Funciones de cadenas
  • Conversion range
  • Val and UNICODE
  • Miscellaneous
WINDEV
WindowsLinuxJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadIOS WidgetApple WatchMac Catalyst
Otros
Procedimientos almacenados
Returns the numeric value of a character string. This feature enables you to perform numeric calculations on strings.
Note: This function is equivalent to StringToNum.
Ejemplo
Val("143")    // Returns 143
Val("1.67")   // Returns 1.67
Val("ABC")    // Returns 0
Val("3plus2") // Returns 3
Val("7,5")    // Returns 7
Val("1D2")    // Returns 100
Val("2.5e-2") // Returns 0.025
Sintaxis
<Result> = Val(<Initial string> [, <Base used>])
<Result>: Real or integer
  • Numeric value of the string.
  • "inf" (for "infinite"), if the result exceeds the capabilities of a real. It is recommended to convert the value to a variable of type int.
  • 0 if an error occurs.
AndroidWidget Android In this version, <Result> corresponds to a real.
<Initial string>: Character string or Buffer
Character string to convert to a numeric value.
For a real, the separator must be the dot ('.') and the prefixes for scientific notation can be 'E', 'e', 'D' or 'd'. If the separator is a comma, the numbers after the comma will be ignored.
This parameter can also be a buffer. In this case, the buffer will be processed differently, according to the option selected in the "Unicode" tab of the configuration description:
  • if "Utilizar cadenas ANSI en tiempo de ejecución" is selected, the buffer will be processed as an ANSI string.
  • if "Utilizar cadenas UNICODE en ejecución" is selected, the buffer will be processed as an ANSI or Unicode string, depending on its content.
<Base used>: Character string or integer (optional)
Base in which the number is represented. The possible values are as follows:
  • "d": base 10 (decimal),
  • "x": base 16 (hexadecimal),
  • "o": base 8 (octal),
  • an integer between 2 and 36.
Base 10 is used by default.
Observaciones

Conversion range

Val converts a string to an integer if the value is between -9.223.372.036.854.775.808 and 9.223.372.036.854.775.807.

Val and UNICODE

The <Chaîne initiale> parameter can be in ANSI or Unicode format.
For more details on Unicode, see Unicode management.

Miscellaneous

If a character of <Initial string> cannot be interpreted as a number, Val stops interpreting <Initial string> and returns the number corresponding to the characters already read.
Reals can be converted from base 10 only. In other bases, all characters after "." (point) will be ignored.
Clasificación Lógica de negocio / UI: Código neutro
Componente: wd300vm.dll
Versión mínima requerida
  • Versión 9
Esta página también está disponible para…
Comentarios
Exemplo so_numeros
PROCEDURE so_numeros(recebe)

wvarfim is string
sMyString is string = "0123456789"
Ss is string
vpos is int

For vpos = 1 TO length(recebe)
Ss = middle(recebe, vpos, 1)
If contains(sMyString, Ss)
wvarfim = wvarfim+middle(recebe,vpos,1)
end
end

result wvarfim
Boller
07 05 2024
Exemplo NewVal
Procedure NewVal(texto)

IF texto = "" THEN

RESULT ""

ELSE

p is int

achou is string

nTotal is int = Length(texto)

LOOP(nTotal)

p++

IF IsNumeric(texto[[p]]) = True THEN

achou += texto[[p]]

Else if texto[[p]] = “,” or texto[[p]] = “.”

achou += texto[[p]]

END

END

achou = NoSpace(achou)


RESULT achou

END
Boller
07 05 2024

Última modificación: 27/03/2025

Señalar un error o enviar una sugerencia | Ayuda local