• Jueves 18 de Abril de 2024, 22:58

Autor Tema:  Generar Numeros Aleatorios De Un Valor Min A Un Ma  (Leído 2713 veces)

Zuzunaga

  • Nuevo Miembro
  • *
  • Mensajes: 14
    • Ver Perfil
Generar Numeros Aleatorios De Un Valor Min A Un Ma
« en: Viernes 24 de Noviembre de 2006, 22:51 »
0
Hola ,alguien sabe como generar numeros aleatorios de un valor minimo a un valor maximo.

leoandres

  • Miembro activo
  • **
  • Mensajes: 79
    • Ver Perfil
Re: Generar Numeros Aleatorios De Un Valor Min A Un Ma
« Respuesta #1 en: Viernes 24 de Noviembre de 2006, 23:19 »
0
Saludos..

Documentación de PB.... lee primero...

Description

Obtains a random whole number between 1 and a specified upper limit.

Syntax

Rand ( n )
Argument   Description
n    The upper limit of the range of random numbers you want returned. The lower limit is always 1. The upper limit is 32,767
Return value
A numeric data type, the data type of n. Returns a random whole number between 1 and n inclusive. If n is NULL, Rand returns NULL.
Usage
The sequence of numbers generated by repeated calls to the Rand function is a pseudorandom sequence. You can control whether the sequence is different each time your application runs by calling the Randomize function to initialize the random number generator.


ej:

integer il_numero

il_numero=ran(1000)

Te genera un numero entre 1 y 1000

también...

Description

Initializes the random number generator so that the Rand function begins a new series of pseudorandom numbers.

Syntax

Randomize ( n )
Argument   Description
n    The starting value (seed) for the random number generator. When n is 0, PowerBuilder takes the seed from the system clock and begins a nonrepeatable sequence. A nonzero number generates a different but repeatable sequence for each seed value. n cannot exceed 32,767
Return value
Integer. If n is NULL, Randomize returns NULL. The return value is never used.
Usage
The sequence of numbers generated by repeated calls to the Rand function is a computer-generated pseudorandom sequence. You can use the Randomize function to initialize the random number generator with a value from the system clock, or some other changing value, so that the sequence is always different. For testing purposes, you can select a specific seed value, which you can reuse to make the pseudorandom sequence repeatable each time you run the application.

Include Randomize in the script for the Open event in the application.
leopoldotaylhardat@hotmail.com

Leopoldo Taylhardat

Software, Organización y Sistemas

Maracay, Venezuela


"En computación solo hay una cosa segura...
   que no hay nada seguro" - Leopoldo Taylhardat

"Cada alternativa que tengas durante la búsqueda,
      será una meta en sí misma" - Jorge Olguín.

leoandres

  • Miembro activo
  • **
  • Mensajes: 79
    • Ver Perfil
Re: Generar Numeros Aleatorios De Un Valor Min A Un Ma
« Respuesta #2 en: Viernes 24 de Noviembre de 2006, 23:20 »
0
Disculpa...

ej:

integer il_numero

il_numero=rand(1000)

Te genera un numero entre 1 y 1000
leopoldotaylhardat@hotmail.com

Leopoldo Taylhardat

Software, Organización y Sistemas

Maracay, Venezuela


"En computación solo hay una cosa segura...
   que no hay nada seguro" - Leopoldo Taylhardat

"Cada alternativa que tengas durante la búsqueda,
      será una meta en sí misma" - Jorge Olguín.