1

I'm developing a module for capture Attlogs from a ZKSoftware Fingerprint Biometric and send it to MySQL database using the SDK that came with the CD, so far I manage to connect successfully to the clock, display the logs on a listview, but I got stuck pushing the values on a multidimensional array, i'm sure it's a matter of declaration but I better ask for help... the code is as follows:

Dim thisLog(1) As String
Dim allLogs()() As String = New String()() {}

afterwards where the iteration (i) load the Attlogs in the listview I got:

            thisLog = {sdwEnrollNumber, idwYear.ToString() & "-" + idwMonth.ToString() & "-" & idwDay.ToString() & " " & idwHour.ToString() & ":" & idwMinute.ToString() & ":" & idwSecond.ToString()}
            allLogs(i) = {thisLog(0), thisLog(1)}

The error I'm getting is related to the size of the array, so the question can be resumed in how can I create a rectangular array (2)(n) with every row of the captured data. Thanks in advance

1
  • 1
    From the looks for this, you really want a List(Of String), List(Of String()), or List(Of List(Of String)) instead of String()(). Commented Mar 25, 2015 at 14:57

2 Answers 2

2

I would highly suggest you create a class to store the data in. Have a List(Of LogEntry) afterward. This would make your code a lot easier to read.

Class LogEntry

    Public Property EnrollNumber As String
    Public Property EntryDate As DateTime

    Public Sub New(ByVal enrollNumber As String, ByVal entryDate As DateTime)

        Me.EnrollNumber = enrollNumber
        Me.EntryDate = entryDate

    End Sub

End Class

For adding a new record, you just need to create an instance of that class and add it to the list.

    Dim allLogs As New List(Of LogEntry)

    allLogs.Add(New LogEntry(sdwEnrollNumber, New DateTime(idwYear, idwMonth, idwDay, idwHour, idwMinute, idwSecond)))

Since you'll now have a valid date instead of a concatenation of string, it'll be easy to do manipulation afterward.

    Console.WriteLine(allLogs(0).EnrollNumber)
    Console.WriteLine(allLogs(0).EntryDate.ToString("yyyy-MM-dd HH:mm:ss"))
Sign up to request clarification or add additional context in comments.

Comments

1

how can I create a rectangular array (2)(n) with every row of the captured data?

Use a List:

Dim allLogs As New List(Of String())()

allLogs.Add(New String(1) {sdwEnrollNumber, _
     String.Format("{0}-{1}-{2} {3}:{4}:{5}", _
     idwYear, idwMonth, idwDay, idwHour, idwMinute, idwSecond)} )

I might also use the appropriate DateTime constructor and format string to format that 2nd part, depending on how you get those idw variables in the first place.

1 Comment

thanks, I will format the DateTime this way, the idw variables comes from the SDK function libs, each one is declared as Integer

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.