0

I have a CSV file that will parse and put in an Array this is a DYNAMIC ARRAY after that I will get the difference between the two Arrays but I can't proceed in my computation because my second array can't get the value.

This is what i have got so far

Option Explicit

Private Sub cmd_parse_Click()

Dim adata() As String
Dim time1() As String
Dim holder1, holder2
Dim time2() As String
Dim lngIndex As Integer
Dim totaltime() As String

Do Until ft1.AtEndOfStream
  On Error Resume Next
        a = ft1.ReadLine
        b = a
        p(0) = a
        r = r + 1
        Text1.Text = r
        z = Left(b, 1)
            adata = Split(a, ",")

If Not IsNumeric(z) Then
            For i = 0 To UBound(adata)
                Text3 = adata(i)
                    If Text3 <> "Time Stamp" Then
                        ft2.WriteLine Text3
                    End If
            Next

        Else

If holder1 = "" Then
            time1 = Split(a, ",")
            For lngIndex = 0 To UBound(time1)
                holder1 = time1(lngIndex)
            Next lngIndex

        Else
            time2 = Split(a, ",")
            For lngIndex = 0 To UBound(time2)
                holder2 = time2(lngIndex)
            Next lngIndex

        End If

    'subtract array time1 from time2

        If holder1 <> "" And holder2 <> "" Then
            For lngIndex = 0 To UBound(time2)
                holder3 = time2(lngIndex) - time1(lngIndex)

            Next lngIndex
        End If
  End If
DoEvents

Loop

Can somebody help me please.

0

1 Answer 1

1

you have not completely declared the arrays time1 and time2 and totaltime yet ...

by declaring them with empty () the program doesnt know the size of the array yet ... the array adata() is dimensioned by the split() function, but the other arrays arent

have a look at redim

you probably want time1 to be the same size as adata?:

ReDim time1(UBound(adata)) As String 
Sign up to request clarification or add additional context in comments.

3 Comments

see the edited code above. Why is that my time1 and time2 has a same value?
i already fix it :) I just change the lngIndex of time2 into lngIndexx then it work :) thank you for your big help @Hrqls :)
:-) <--- my cutest smile :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.