Re: Subscript OUT OF RANGE Error

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Jan,

Thanks.. That worked. I hjad not initialized my array. Now I modified my
code a little bit like th efollowing and it worked, :)

Private Sub btnUpload_Click()


Dim SubDir() As String


Dim i As Integer

Dim CountDir As Integer
CountDir = dirDirect.ListCount

ReDim SubDir(CountDir)
For i = 0 To CountDir - 1
SubDir(i) = dirDirect.List(i)

Next
For i = 0 To dirDirect.ListCount - 1
MsgBox SubDir(i)
Next
End Sub
--
pmud


"Jan Hyde" wrote:

pmud <pmud@xxxxxxxxxxxxxxxxxxxxxxxxx>'s wild thoughts were
released on Thu, 18 May 2006 06:25:01 -0700 bearing the
following fruit:

Hi Karl,

I think I by chance wrote wrong here.

You should always post your exact code rather than typing it
out again.

I apologize. But in my code SubDirPath
i9s an array and still I am getting teh subscript out of range error. Below
is my corrcte code:
Private Sub btnUpload_Click()

Dim SubDirPath() As String
Dim i As Integer

For i = 0 To dirDirect.ListCount - 1
SubDirPath(i) = dirDirect.List(i) ---- ERROR HERE
Next


Anyhoo, where exactly do you initialise that array?


Jan Hyde (VB MVP)

--
The convicted architect discovered that prison walls were not made to scale. (Gary Hallock)


.



Relevant Pages

  • RE: Make all variable values in a Array equal to 0
    ... Dim var1 As Single ... Private Sub btnApply_Click ... just figured using an Array would reset the variables. ... Lether Seats (CheckBox1 and var1) ...
    (microsoft.public.excel.programming)
  • RE: Make all variable values in a Array equal to 0
    ... Dim var1 As Single ... Private Sub btnApply_Click ... just figured using an Array would reset the variables. ... Lether Seats (CheckBox1 and var1) ...
    (microsoft.public.excel.programming)
  • RE: Make all variable values in a Array equal to 0
    ... just figured using an Array would reset the variables. ... Dim ary() As Single ... Private Sub btnApply_Click ... Lether Seats (CheckBox1 and var1) ...
    (microsoft.public.excel.programming)
  • Re: Giving mouse movement lag
    ... Your REDIM is wiping out the values in the tables before they get processed. ... Dim iXAs Integer ... Private Sub Form1_Click(ByVal sender As Object, ... The idea is, Form1_MouseMove adds the current mouse coords to an array, and also the current time to a secondary array. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Giving mouse movement lag
    ... use ReDim Preserve instead. ... Dim iXAs Integer ... Private Sub Form1_Click(ByVal sender As Object, ... Form1_MouseMove adds the current mouse coords to an array ...
    (microsoft.public.dotnet.languages.vb)