I have what should be simple but I am stumped.
I have a class to store an array that is accessable from several other classes.
I have a class.add method, that addes a new entry to the array.
My problem is it adds the new data but the previous item becomes nothing.
and the routine that initially loads the data into the class.
There is also another 2 forms that needs to access and read /add entries
I have a class to store an array that is accessable from several other classes.
I have a class.add method, that addes a new entry to the array.
My problem is it adds the new data but the previous item becomes nothing.
VB.NET:
Public Class MyLicense 'holds the array of licenses and MAC addresses
Private _mac() As String
Private _license() As String
Private _site() As String
Public Sub add(ByRef m_mac As String, ByRef m_license As String, ByRef m_site As String)
Dim a As Int16 = Me.count
ReDim _mac(a)
ReDim _license(a)
ReDim _site(a)
_mac(a) = m_mac
_license(a) = m_license
_site(a) = m_site
End Sub
Public Function count() As Integer
Try
count = _mac.Length
Catch ex As Exception
count = 0
End Try
End Function
Public ReadOnly Property Mac(ByVal index) As String
Get
Return _mac(index)
End Get
End Property
Public ReadOnly Property License(ByVal index) As String
Get
Return _license(index)
End Get
End Property
Public ReadOnly Property Site(ByVal index) As String
Get
Return _site(index)
End Get
End Property
End Class
and the routine that initially loads the data into the class.
There is also another 2 forms that needs to access and read /add entries
VB.NET:
Public Sub Licenses_Load()
Dim registry As New RegistryTools
'TODO: load registry to string array
Dim RegistryPath As String = "Nortronics\Indigo\Licenses"
Dim LicenseCount As Integer = registry.GetKeyCount(RegistryPath) 'count the number of licenses in registry
' ReDim myLicenses(LicenseCount)
Dim SubKeyName As String
Dim Result(2) As String
Dim a As Integer
'get and array of the registry entries for MAC Address, License and Site.
'index starts from 1
For a = 1 To LicenseCount
SubKeyName = "Key" & a
If registry.DoesSubKeyExist(RegistryPath, SubKeyName) Then
Result(0) = registry.GetValue(RegistryPath & "\" & SubKeyName, "MAC")
Result(1) = registry.GetValue(RegistryPath & "\" & SubKeyName, "License")
Result(2) = registry.GetValue(RegistryPath & "\" & SubKeyName, "Site")
myLicenses.add(Result(0), Result(1), Result(2))
End If
Next
'TODO: if license is demo, start program time and display anoyance message
End Sub