I am having an issue with arrays in vb.net.
I have a class called variables that contains the following:
Then I have a shared sub in my general code class like the following:
So I load the array AcctCal, it works fine, but when I execute the last End If, AcctCal turns to nothing. How come it is not saving? I need to array to exist for use in different parts of the program. So It should be shared, correct? What am I missing?
Please help.
David
I have a class called variables that contains the following:
VB.NET:
Public Class Variables
Public Shared AcctCal() As udtCalendar
Structure udtCalendar
Public DPP As Integer
Public BegDt As Date
Public EndDt As Date
Public Year As Integer
Public AvailHrs As Single
End Structure
End Class
Then I have a shared sub in my general code class like the following:
VB.NET:
Public Class general
Public Shared Sub LoadAcctCal()
oracle_rs = New ADODB.Recordset
'Load the Accounting Calendar Array...
sqlstr = "Select ************************"
oracle_rs.Open(sqlstr, oracle_conn)
oracle_rs.MoveFirst()
If oracle_rs.RecordCount <> 0 Then
Dim AcctCal() As udtCalendar
lngRecs = 0
Do Until oracle_rs.EOF
If Len(oracle_rs(0).Value & "") <> 0 Then
ReDim Preserve AcctCal(lngRecs)
AcctCal(lngRecs).DPP = CInt(oracle_rs(0).Value)
AcctCal(lngRecs).BegDt = Format(CDate(oracle_rs(1).Value), "MM/dd/yyyy")
AcctCal(lngRecs).EndDt = Format(CDate(oracle_rs(2).Value), "MM/dd/yyyy")
AcctCal(lngRecs).Year = CInt(oracle_rs(3).Value)
AcctCal(lngRecs).AvailHrs = CSng(oracle_rs(4).Value)
oracle_rs.MoveNext()
End If
lngRecs = lngRecs + 1
Loop
End If
oracle_rs.Close()
End Sub
So I load the array AcctCal, it works fine, but when I execute the last End If, AcctCal turns to nothing. How come it is not saving? I need to array to exist for use in different parts of the program. So It should be shared, correct? What am I missing?
Please help.
David