Help - Creating Random function?

Results 1 to 2 of 2

Thread: Help - Creating Random function?

  1. #1
    Join Date
    Dec 1969

    Default Help - Creating Random function?

    Need help creating random textfile: Trying to use the following to create random number.<BR><BR>I get an "object" error pointing to the "lcrnd" in the CreateTextFile paramater. Can I not place a variable in the path. Please advise. Thanks.<BR><BR>Context - I&#039m creating a text file for faxing and need each new file to have different name.<BR><BR>nLowerBound= [1]<BR>nUpperbound=[9]<BR>Randomize<BR>lcrnd = ((nUpperbound - nLowerbound + 1) * Rnd + nLowerbound) <BR><BR><BR>Function CreateFaxFile(c_string) <BR>Const ForReading = 1, ForWriting = 2, ForAppending = 8<BR>Dim objFSO, objF, ts, mytext<BR>Set objFSO = Server.CreateObject("Scripting.FileSystemObject")< BR><BR>Set OutStream = objFSO.CreateTextFile("d:httpplm empdata\" + lcrnd + ".txt", 8)<BR><BR>OutStream.Write(strBody)<BR>OutStream.Cl ose<BR><BR>Set OutStream = Nothing<BR>Set objFSO = Nothing<BR>End Function

  2. #2
    Join Date
    Dec 1969

    Default RE: Help - Creating Random function?

    String concatenation in VBScript is done with an ampersand rather than a plus sign... so, you should do:<BR><BR>Set OutStream = objFSO.CreateTextFile("d:httpplm empdata\" & lcrnd & ".txt", 8)<BR><BR><BR>(Note the ampersands have replaced the plus signs!)<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts