Instr() or Loop??

Results 1 to 2 of 2

Thread: Instr() or Loop??

  1. #1
    Join Date
    Dec 1969

    Default Instr() or Loop??

    I&#039;m going to keep an array of permissions inside a cookie using join(). On every page I need to read that cookie and see if the current page is in that array (i need to see if the user has permissions to view it). <BR><BR>Since this is such a simple 1 dimension array, would it be faster to use instr() or loop? I anticipate the cookie to hold 5 to 10 numbers comma delimited. <BR><BR>What do you think?

  2. #2
    Join Date
    Dec 1969

    Default RE: Instr() or Loop??

    Instr, I&#039;d say. But you could always do a quick test :)<BR><BR>&#060;%<BR>Function DoInstr()<BR> DoInstr = InStr(1, myString, "3")<BR>End Function<BR>Function DoLoop()<BR> &#039; However you were going to do your loop<BR>End Function<BR><BR>Dim start: start = Timer()<BR>Dim intCounter<BR>For intCounter = 0 To 500<BR> Call DoInstr()<BR>Next<BR>Response.Write "Took " & (Timer() - start) & " seconds to do instr.&#060;br/&#062;"<BR>Response.Flush<BR>start = Timer()<BR>For intCounter = 0 To 500<BR> Call DoLoop()<BR>Next<BR>Response.Write "Took " & (Timer() - start) & " seconds to do loop.&#060;br/&#062;"<BR>Response.Flush<BR><BR>%&#062;<BR><BR>Cr aig.

Posting Permissions

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