C
Co
Hi All,
I created a Structure
Public Structure FolderID
Private FolderID As Integer
Private FolderName As String
Public Sub New(ByVal myFolderID As Integer, ByVal myFolderName
As Integer)
FolderID = myFolderID
FolderName = myFolderName
End Sub
Public Property FolderIDValue() As Integer
Get
Return FolderID
End Get
Set(ByVal Value As Integer)
FolderID = Value
End Set
End Property
Public Property FolderNameValue() As String
Get
Return FolderName
End Get
Set(ByVal Value As String)
FolderName = Value
End Set
End Property
Public Overrides Function ToString() As String
Return [String].Format("{0}, {1}", FolderID, FolderName)
End Function
End Structure
Now I want to fill this with data from a Listbox.
Public xFolder() As FolderID
Private Sub LoadListBoxes()
Dim sql As String = "SELECT * FROM Kabinet"
Dim strTable As String = "Kabinet"
Dim da As New OleDb.OleDbDataAdapter(sql, conn)
Dim ds As New DataSet
conn.Open()
Try
da.SelectCommand = New OleDb.OleDbCommand(sql, conn)
da.Fill(ds, strTable)
Dim dr As DataRow
Dim i As Integer = ds.Tables(0).Rows.Count - 1
Dim j As Integer = 0
Dim xfolder(i) As FolderID
For Each dr In ds.Tables(0).Rows
ListBox1.Items.Add(dr.Item("foldername"))
xFolder(j).FolderIDValue = dr.Item("Id")
xfolder(j).FolderNameValue = dr.Item("foldername")
j += 1
Next
Catch oException As OleDbException
MessageBox.Show(oException.Message)
Catch oException As Exception
MessageBox.Show(oException.Message)
End Try
conn.Close()
End Sub
Now from a function I want to read data from the array but it's empty:
Private Function GetRightFolderID(ByVal sListValue As String) As
String
Dim e As FolderID
For Each e In xFolder
If sListValue = e.FolderNameValue Then
Return e.FolderIDValue
End If
Next e
Return Nothing
End Function
What am I doing wrong?
Regards
Marco
The Netherlands
I created a Structure
Public Structure FolderID
Private FolderID As Integer
Private FolderName As String
Public Sub New(ByVal myFolderID As Integer, ByVal myFolderName
As Integer)
FolderID = myFolderID
FolderName = myFolderName
End Sub
Public Property FolderIDValue() As Integer
Get
Return FolderID
End Get
Set(ByVal Value As Integer)
FolderID = Value
End Set
End Property
Public Property FolderNameValue() As String
Get
Return FolderName
End Get
Set(ByVal Value As String)
FolderName = Value
End Set
End Property
Public Overrides Function ToString() As String
Return [String].Format("{0}, {1}", FolderID, FolderName)
End Function
End Structure
Now I want to fill this with data from a Listbox.
Public xFolder() As FolderID
Private Sub LoadListBoxes()
Dim sql As String = "SELECT * FROM Kabinet"
Dim strTable As String = "Kabinet"
Dim da As New OleDb.OleDbDataAdapter(sql, conn)
Dim ds As New DataSet
conn.Open()
Try
da.SelectCommand = New OleDb.OleDbCommand(sql, conn)
da.Fill(ds, strTable)
Dim dr As DataRow
Dim i As Integer = ds.Tables(0).Rows.Count - 1
Dim j As Integer = 0
Dim xfolder(i) As FolderID
For Each dr In ds.Tables(0).Rows
ListBox1.Items.Add(dr.Item("foldername"))
xFolder(j).FolderIDValue = dr.Item("Id")
xfolder(j).FolderNameValue = dr.Item("foldername")
j += 1
Next
Catch oException As OleDbException
MessageBox.Show(oException.Message)
Catch oException As Exception
MessageBox.Show(oException.Message)
End Try
conn.Close()
End Sub
Now from a function I want to read data from the array but it's empty:
Private Function GetRightFolderID(ByVal sListValue As String) As
String
Dim e As FolderID
For Each e In xFolder
If sListValue = e.FolderNameValue Then
Return e.FolderIDValue
End If
Next e
Return Nothing
End Function
What am I doing wrong?
Regards
Marco
The Netherlands