Guest Pat Report post Posted 04/10/2003 10:12 PM I've tried variations for obtaining a random number, but I always get the SAME number. I.E. It'll give me a random number, BUT, each time I call and run the script I always get the SAME number. Can someone help ?? Thanks Share this post Link to post
SupportTeam Report post Posted 04/11/2003 02:33 AM You will have to call the Randomize() function first.. Here is a demo VB Script which generates a random number between 0 and 999 (easy to modify for other ranges). You can use in a "Run VBScript" module, after running that module you will be able to access the random value elsewhere in the script using the Result Variable $RV[Random]. Make sure to select the "Wait until VB Script Finishes" option, otherwise the result of the script will not be read in by VoiceGuide! dim iRandomNumber, strResultVariables Randomize() iRandomNumber = Int((1000 * Rnd)) strResultVariables= "[Random]{" & iRandomNumber & "}" iRet = WriteResultFile(strResultVariables) function WriteResultFile(strResult) const ForReading=1, ForWriting=2, ForAppending=8 Dim filename, fso, ts, outdata, outdata2, outdata3 filename = "VGRUNRESULT_$RV_DEVICEID.TXT" set fso = CreateObject("Scripting.FileSystemObject") set ts = fso.OpenTextFile(filename, ForWriting, True) ts.WriteLine(strResult) ts.Close WriteResultFile = 0 end function Share this post Link to post
Guest Pat Report post Posted 04/13/2003 05:39 PM THANKS ! It worked very well. Is there a way to use or run the VB script using the older 2.9 version of voiceguide ?? Is there a way to generate RANDOM numbers using the 2.9 version of voiceguide ?? Thanks Share this post Link to post
SupportTeam Report post Posted 04/13/2003 11:30 PM With v2.9 you would need to run the vbscript using the WSCRIPT.EXE or CSCRIPT.EXE tools installed in Window's SYSTEM32 directory- calling them using the Run Program module. You would need to modify the returned result.txt file to be of the format expected by v2.9: The contents would be (example): SUCCESSS 724 Share this post Link to post
Guest fsoudbakhsh Report post Posted 08/16/2004 06:43 AM Is this VB script generate unique random number or repeated random number? Would you please also teach me how to change VB scrip from 3 digits to 12 digits? I need to generate the card number and the card number should be unique and 12 digit. Thanks Farzad Share this post Link to post
SupportTeam Report post Posted 08/16/2004 07:34 AM Just generate four 3 digit numbers and the concatenate them together (as strings) - then you'll get a 12 digit number (as a string). NB. This is not really a VoiceGuide related question - I'd suggest speaking to your local programmers for non-VoiceGuide related questions instead of posting them on this forum... Share this post Link to post