Results 1 to 17 of 17

Thread: subscript out of range

Threaded View

  1. #1

    Thread Starter
    Addicted Member aturner's Avatar
    Join Date
    Nov 2000
    Posts
    179

    Resolved subscript out of range

    VB Code:
    1. Option Explicit
    2.  
    3. Public prntr As Printer
    4. Public tempstr As String
    5. Public tempint As Integer
    6. Public longname As String
    7. Public shortname As String
    8.  
    9.  
    10. Private Sub cmdExit_Click()
    11.     Unload Me
    12. End Sub
    13.  
    14. Private Sub Form_Load()
    15. Dim names() As String
    16. Dim intcount As Integer
    17. intcount = 0
    18.     For Each prntr In Printers
    19.         If Mid(prntr.DeviceName, 3, 5) = "srver" Then
    20.            intcount = intcount + 1
    21.            'resize array to fit added data
    22.            ReDim Preserve names(intcount, 2)
    23.            'add the full string to the array
    24.            names(intcount, 1) = prntr.DeviceName
    25.            shortname = Right(prntr.DeviceName, 3)
    26.            'add the short string to the array
    27.            names(intcount, 2) = shortname
    28.            'add the short name to the listbox
    29.            List1.AddItem names(intcount, 2)
    30.         End If
    31.     Next prntr
    32. End Sub

    as soon as intcount = 2 i get subscript out of range ... can anyone spot the mistake .... i'm lost on this
    Last edited by aturner; Apr 12th, 2005 at 09:22 AM.
    Due to the energy crisis, the light at the end of the tunnel has been turned off.
    Sorry for any inconvenience this may cause

Posting Permissions

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



Click Here to Expand Forum to Full Width