VB Code:
Option Explicit Public prntr As Printer Public tempstr As String Public tempint As Integer Public longname As String Public shortname As String Private Sub cmdExit_Click() Unload Me End Sub Private Sub Form_Load() Dim names() As String Dim intcount As Integer intcount = 0 For Each prntr In Printers If Mid(prntr.DeviceName, 3, 5) = "srver" Then intcount = intcount + 1 'resize array to fit added data ReDim Preserve names(intcount, 2) 'add the full string to the array names(intcount, 1) = prntr.DeviceName shortname = Right(prntr.DeviceName, 3) 'add the short string to the array names(intcount, 2) = shortname 'add the short name to the listbox List1.AddItem names(intcount, 2) End If Next prntr End Sub
as soon as intcount = 2 i get subscript out of range ... can anyone spot the mistake .... i'm lost on this




Reply With Quote