troubleshooting Question

vbs compilation error expected end of statement

Avatar of 01010011
01010011 asked on
Visual Basic Classic
2 Comments1 Solution976 ViewsLast Modified:
This is a vb script to generate a random password but I get an error saying that it expected end of statement at line 3 char 17. Please help. Thanks.
Here is the script:

'Form code - frmPasswordGenerate
 
Private Declare Function GetTickCount Lib "kernel32" () As Long
 
Public Function PassGen(nLen As Integer)
Dim range As Collection
Dim ivalue, icount, iLen As Long
Dim pass As String
 
    Set range = New Collection
    range.Add ("0")
    range.Add ("1")
    range.Add ("2")
    range.Add ("3")
    range.Add ("4")
    range.Add ("5")
    range.Add ("6")
    range.Add ("7")
    range.Add ("8")
    range.Add ("9")
 
    icount = 0
    ivalue = 0
    iLen = range.Count
   
    Do Until icount = nLen
      Randomize
      ivalue = CByte(Mid(CStr(Rnd(GetTickCount)), 3, 2))
       If ivalue > 0 And ivalue <= iLen Then
          icount = icount + 1
          pass = pass & range(ivalue)
       End If
    Loop
 
PassGen = pass
End Function
 
Private Sub cmdGeneratePassword_Click()
    MsgBox PassGen(8)
End Sub

--------------------------------------------------------------------------------

ASKER CERTIFIED SOLUTION
PaulHews

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros