Siebel VB Language Reference > VB Language Reference >

Randomize Statement


This standard VB statement seeds the random number generator.

Syntax

Randomize [number]

Argument
Description

number

An integer value between -32768 and 32767

Returns

Not applicable

Usage

If no number argument is given, Siebel VB uses the Timer function to initialize the random number generator.

Example

This example generates a random string of characters using the Randomize statement and Rnd function. The second For...Next loop is to slow down processing in the first For...Next loop so that Randomize can be seeded with a new value each time from the Timer function.

Sub Button_Click
   Dim x As Integer, y As Integer
   Dim str1 As String, str2 As String
   Dim letter As String
   Dim randomvalue
   Dim upper, lower
   Dim msgtext
   upper = Asc("z")
   lower = Asc("a")
   newline = Chr(10)
   Randomize
   For x = 1 to 26
      randomvalue = Int(((upper - (lower + 1)) * Rnd) + lower)
      letter = Chr(randomvalue)
      str1 = str1 & letter
      For y = 1 to 1500
      Next y
   Next x
      msgtext = str1
End Sub

See Also

Rnd Function
Timer Function

Siebel VB Language Reference