In reply to Dharak Modi:
The call to randomize must be inside a class method. Can you show your complete code.