Firstly, sorry if this is in the wrong forum and also for the amount of code posted. I thought by posting them you would be able to see and understand what it is i am trying to do.
I am writing a database using OOP, i have created my classes ect and i am able to input data.
Now to the problem.
I have four textboxs, and two listbox's. The first listbox lists all the categories which i have managed to do. Now when the user selects a catelgory a list of objects under that category are listed in the second listbox which the user then selects to display any related data and this is the problem i am having.
This is some of the code:
Public Class BaseClass
' ScrName is the name of the script file.
Public Property ScrName() As String
' Usage is what to do with the script.
Public Property Usage() As String
' Desc is the description of what the script does.
Public Property Desc() As String
' Script is the script file it's self.
Public Property Script() As String
' Gets the Version of the Script. Either X9 or X10
Public Property Xver() As String
' Holds weather script is compateble with each version. X9 Only, X10 Only or both X9 & X10
Public Property Compat() As String
' Holds additional information of what the script.
Public Property AddInfo() As String
' Hold the date script was added
Public Property Dateadded() As String
Public Property Scriptcount() As String
This is my Records class which Inherits the Baseclass:
Public Class Record
Public Property Catel As String
' Electronics Sub-Category Data
Public Property Electronics As New Electronics
' Enemies Sub-Category Data
Public Property Enemies As New Enemies
And this is one of the categories:
Public Class Electronics
Public Sub New()
Public Sub New(ByVal scrName As String, ByVal usage As String, ByVal desc As String, ByVal script As String, ByVal xver As String, _
ByVal compat As String, ByVal addInfo As String, ByVal dateadded As String, ByVal scriptcount As String)
Me.Desc = desc
Me.Usage = usage
Me.ScrName = scrName
Me.Script = script
Me.Xver = xver
Me.Compat = compat
Me.AddInfo = addInfo
Me.Dateadded = dateadded
Me.Scriptcount = scriptcount
This code populates the first listbox with the categories.
The next two bits of code are what i am having trouble with.
Public Class ViewScripts
Private Sub ViewScripts_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Add list of categories to listbox
For Each f As String In Catelog
This code allows the user to select a category which then populates the second listbox with the data stored under that category.
Private Sub CatelogList_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles CatelogList.SelectedIndexChanged
' Grab the category from the list
Dim CurrentRecord As Record = ListOfRecords.Item(CatelogList.SelectedIndex)
' Load Cat with the selected category.
Cat = CatelogList.SelectedItem
Dim CatSelected As String = Cat
' Add list of catelogs to listbox
' Now populate listbox two with any objects stored under category.
For Each f As String In CurrentRecord.ScrName
Now, when the second listbox is populated, the user can then select any of the objects in listbox 2 and display it's contents in the relevant textboxs.
Private Sub ScriptList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ScriptList.SelectedIndexChanged
Dim selectedRecord As New Record
For Each checkRecord As Record In ListOfRecords
If checkRecord.ScrName = CatelogList.SelectedItem.ToString Then
ScriptUsage.Text = checkRecord.Usage
ScriptDescription.Text = checkRecord.Desc
AddInfo.Text = checkRecord.AddInfo
ScriptView.Text = checkRecord.Script
As you already knows that this does not work.
I have been stuck on this for weeks and would be greatful to anyone who can help me with this.