Hey guys! Its me again.

I'm working with a SQLite database, and I want to list every entry inside a listbox (only the "Name" row). I know that I can list everything inside a DataGrid, but I don't want to list everything (:

Also... sometimes, when you open a window inside a app, you can't work with other windows until that one you opened gets closed. How can I do it too?

Also, I've created two context menus. Is everything working fine, but they look too... strange. The windows default looks like this: http://i1001.photobucket.com/albums/af134/RenanLazarotto/screen_000007.png

But, mine is looking like this, after I changed the render to 'System': http://i1001.photobucket.com/albums/af134/RenanLazarotto/screen_000008.png

Can I make it look like windows default?

Well, I think that this is all for now. Thanks!

I'm working with a SQLite database, and I want to list every entry inside a listbox (only the "Name" row)

You do use System.Data.SQLite? Do the binding with ListBox as you do normally but select only "Name" column from the underlying DB.

when you open a window inside a app, you can't work with other windows until that one you opened gets closed.

Forms can be modal or modeless and the ones your talking are modal forms:

Dim oForm As New Form2
oForm.Show() ' Modeless form
oForm.ShowDialog() ' Modal form

Can I make it look like windows default?

Yes. This makes it pretty close, only vertical line is missing:

Dim MenuItem As ToolStripMenuItem
Dim MenuSeparator As ToolStripSeparator

' Clear context menu
ContextMenuStrip1.Items.Clear()
' Add first menu item
MenuItem = New ToolStripMenuItem("New")
ContextMenuStrip1.Items.Add(MenuItem)
' Add menu item separator
MenuSeparator = New ToolStripSeparator
ContextMenuStrip1.Items.Add(MenuSeparator)
' Add second menu item
MenuItem = New ToolStripMenuItem("Add")
ContextMenuStrip1.Items.Add(MenuItem)

and do not change rendermode to 'System'. Getting that vertical line between image margin and menu text was too tricky :)

HTH

You do use System.Data.SQLite? Do the binding with ListBox as you do normally but select only "Name" column from the underlying DB.

Yeah. I've added it, seems that it is working fine. (:

Forms can be modal or modeless and the ones your talking are modal forms:

Dim oForm As New Form2
oForm.Show() ' Modeless form
oForm.ShowDialog() ' Modal form

I don't got the mean of 'modal' word (I'm brazilian, my primary language isn't english :P), but it worked as I wanted. Thanks!

Yes. This makes it pretty close, only vertical line is missing:

Dim MenuItem As ToolStripMenuItem
Dim MenuSeparator As ToolStripSeparator

' Clear context menu
ContextMenuStrip1.Items.Clear()
' Add first menu item
MenuItem = New ToolStripMenuItem("New")
ContextMenuStrip1.Items.Add(MenuItem)
' Add menu item separator
MenuSeparator = New ToolStripSeparator
ContextMenuStrip1.Items.Add(MenuSeparator)
' Add second menu item
MenuItem = New ToolStripMenuItem("Add")
ContextMenuStrip1.Items.Add(MenuItem)

and do not change rendermode to 'System'. Getting that vertical line between image margin and menu text was too tricky :)

HTH

Almost what I wanted (: So bad that it looks like Office 2003 or so. :/

Well, now are more questions: when I list what I want inside the listbox, how can I make it functional? I mean... I select a entry, double click on it and then it opens a window with the info of the selected item. Hm... to get the right entry, it should read its ID and open the infos based on it, right?

Just one more... There is some way to create animated controls? I'll try to explain... I've saw it in some apps. You click a button (or image or whatever) and it grow and everything else dispose, and a new "page" appears, with info on the item you clicked (I think that is mostly common on media players). There is a way to do it in VB.net?

I think that I need to shut up for now :D Thanks in advance!

Hm... more things here.
To not create another topic...

How can I pass a value when I right click a control? Like... My form has 15 picture boxes, and I've set to each one a tag value, increasing from 1 to 15. When I right click a random picture box, and select the context entry that needs a value to load, I need that it get its value from the tag of the picture box that I've right clicked. Can I do it?

Also, There is some way to dinamically increase a name? Like... when my app runs, it gets the needed data to build the form from a database. In the database, I've created a collumn that has the interface ID (IID), which also ranges from 1 to 15. When the form loads, it reads the Interface ID and place the info on the right ID on the interface... but I've been doing this with ifs:

Try
            Dim SQLconnect As New SQLite.SQLiteConnection()
            Dim SQLcommand As SQLiteCommand
            Dim InterfaceID As Integer

            'define string de conexão com banco de dados SQLite - Macoratti.db criado na pasta c:\dados
            'usando a criptografia
            SQLconnect.ConnectionString = "Data Source=data\games.db3;Version=3;New=True;Compress=True;"

            'abre a conexão
            SQLconnect.Open()

            'cria um comando
            SQLcommand = SQLconnect.CreateCommand

            'define a instrução sql
            SQLcommand.CommandText = "SELECT * FROM Jogos ORDER By ID"

            'executa o comando e retorna um datareader
            Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()

            'percorre e exibe os dados
            While SQLreader.Read()
                InterfaceID = SQLreader("InterfaceID")

                If InterfaceID = 1 Then
                    GameName1.Text = SQLreader("Nome")
                    If SQLreader("ícone").Equals(System.DBNull.Value) Then
                        Icon1.Image = Nothing
                    Else
                        Icon1.Image = BlobToImage(SQLreader("ícone"))
                    End If

                ElseIf InterfaceID = 2 Then
                    GameName2.Text = SQLreader("Nome")
                    If SQLreader("ícone").Equals(System.DBNull.Value) Then
                        Icon2.Image = Nothing
                    Else
                        Icon2.Image = BlobToImage(SQLreader("ícone"))
                    End If

                ElseIf InterfaceID = 3 Then
                    GameName3.Text = SQLreader("Nome")
                    If SQLreader("ícone").Equals(System.DBNull.Value) Then
                        Icon3.Image = Nothing
                    Else
                        Icon3.Image = BlobToImage(SQLreader("ícone"))
                    End If

                ElseIf InterfaceID = 4 Then
                    GameName4.Text = SQLreader("Nome")
                    If SQLreader("ícone").Equals(System.DBNull.Value) Then
                        Icon4.Image = Nothing
                    Else
                        Icon4.Image = BlobToImage(SQLreader("ícone"))
                    End If

                ElseIf InterfaceID = 5 Then
                    GameName5.Text = SQLreader("Nome")
                    If SQLreader("ícone").Equals(System.DBNull.Value) Then
                        Icon5.Image = Nothing
                    Else
                        Icon5.Image = BlobToImage(SQLreader("ícone"))
                    End If
                End If
            End While

            SQLcommand.Dispose()
            SQLconnect.Close()

        Catch ex As Exception
            MsgBox("Erro ao acessar o SQLite: " & ex.Message)
        End Try

This generates a huge code... there is some way to increase or decrease the 'name' based on the IID number? Like... When IID number is 4 set labels number to 4 too.

Phew.. I think that for now is really everything. Thanks again!

I reply to both posts at the same time.

I don't got the mean of 'modal' word (I'm brazilian, my primary language isn't english )

My primary language isn't English either :D

I select a entry, double click on it and then it opens a window with the info of the selected item. Hm... to get the right entry, it should read its ID and open the infos based on it, right?

Yes, if that's what you want. I won't show the code to open a form, but how to get some associated ID from a ListBox item. I assume that ListBox is databound to DB:

Dim TempID As Integer ' ID's are stored in ListBox item's Tag property (i.e. ValueMember is set to Tag property
' Make sure that an item is actually selected (exactly one item)
If ListBox1.SelectedIndices.Count = 1 Then
  TempID = CInt(ListBox1.SelectedValue)
  ' Use ID value...
  ' A more safer way would be to use If Integer.TryParse(ListBox1.SelectedValue, TempID) Then ...
End If

There is some way to create animated controls? I'll try to explain... I've saw it in some apps. You click a button (or image or whatever) and it grow and everything else dispose, and a new "page" appears, with info on the item you clicked (I think that is mostly common on media players). There is a way to do it in VB.net?

I don't see any reason why you couldn't do that (in VB.NET). Programming graphics is a bit large topic, so I suggest to ask this one in a new thread. Before doing that, make yourself clear exactly what you want and secondly, learn the basics of graphics programming. Use a search engine to find tutorials and sample codes and play with them first to familiarize yourself with .NET's graphics objects.

there is some way to increase or decrease the 'name' based on the IID number? Like... When IID number is 4 set labels number to 4 too.

Yes. Here's a bit generic way to access controls and use their properties. This is just an example:

' How to loop object's control collection to find specific controls:

' Loop this form and get labels with a name Labelx where x is a number
' change the Text property of these labels
Dim oControl As Control
Dim TempStr As String
Dim TempInt As Integer

For Each oControl In Me.Controls ' Me refers to this form, but could be any object with Control container
    ' Is this a label?
    If TypeOf oControl Is Label Then
        ' It's a label. Does it have a name like 'Labelx'
        TempStr = DirectCast(oControl, Label).Name ' Get the name of this label
        ' Notice: a Control object has Name property, but it's a good practise to cast Control object to specific type (like Label in this case)
        If TempStr.Length > 5 AndAlso TempStr.Substring(0, 5) = "Label" AndAlso
            Integer.TryParse(TempStr.Substring(5, TempStr.Length - 5), TempInt) Then
            ' Label's name is in format 'Labelx'. TempInt has the numeric value
            DirectCast(oControl, Label).Text = "I am label number " & TempInt.ToString ' Change the Text property
        End If
    End If
Next

In your code, you wouldn't loop through the controls because you know their name and you want to access a specific control by it's name:

' Change a specific label's text (a label with name Label2)
' The test could be done with If Me.Controls.Contains(Label2) Then ...
' but we want the index of this control to refer it later
Dim ControlIX As Integer
Dim TempIX As Integer
ControlIX = 2
TempIX = Me.Controls.IndexOfKey("Label" & ControlIX.ToString)
' .... refer to control later
DirectCast(Me.Controls.Item(TempIX), Label).Text = "I am label number 2 showing this text"

The variable ControlIX is now used to find the specific Label in the line TempIX = Me.Controls.IndexOfKey("Label" & ControlIX.ToString) HTH

Yes, if that's what you want. I won't show the code to open a form, but how to get some associated ID from a ListBox item. I assume that ListBox is databound to DB:

Dim TempID As Integer ' ID's are stored in ListBox item's Tag property (i.e. ValueMember is set to Tag property
' Make sure that an item is actually selected (exactly one item)
If ListBox1.SelectedIndices.Count = 1 Then
  TempID = CInt(ListBox1.SelectedValue)
  ' Use ID value...
  ' A more safer way would be to use If Integer.TryParse(ListBox1.SelectedValue, TempID) Then ...
End If

Hm... I recieve an error saying that a conversion of DataRowView to Interger is not valid. Maybe I forget to say, but, when I double click it, it will read the associated ID on the database :P

Yes. Here's a bit generic way to access controls and use their properties. This is just an example:

' How to loop object's control collection to find specific controls:

' Loop this form and get labels with a name Labelx where x is a number
' change the Text property of these labels
Dim oControl As Control
Dim TempStr As String
Dim TempInt As Integer

For Each oControl In Me.Controls ' Me refers to this form, but could be any object with Control container
    ' Is this a label?
    If TypeOf oControl Is Label Then
        ' It's a label. Does it have a name like 'Labelx'
        TempStr = DirectCast(oControl, Label).Name ' Get the name of this label
        ' Notice: a Control object has Name property, but it's a good practise to cast Control object to specific type (like Label in this case)
        If TempStr.Length > 5 AndAlso TempStr.Substring(0, 5) = "Label" AndAlso
            Integer.TryParse(TempStr.Substring(5, TempStr.Length - 5), TempInt) Then
            ' Label's name is in format 'Labelx'. TempInt has the numeric value
            DirectCast(oControl, Label).Text = "I am label number " & TempInt.ToString ' Change the Text property
        End If
    End If
Next

In your code, you wouldn't loop through the controls because you know their name and you want to access a specific control by it's name:

' Change a specific label's text (a label with name Label2)
' The test could be done with If Me.Controls.Contains(Label2) Then ...
' but we want the index of this control to refer it later
Dim ControlIX As Integer
Dim TempIX As Integer
ControlIX = 2
TempIX = Me.Controls.IndexOfKey("Label" & ControlIX.ToString)
' .... refer to control later
DirectCast(Me.Controls.Item(TempIX), Label).Text = "I am label number 2 showing this text"

The variable ControlIX is now used to find the specific Label in the line TempIX = Me.Controls.IndexOfKey("Label" & ControlIX.ToString) HTH

This seems nice, appears to do exactly what I want, but how can I implement it on my code? I mean... load the app -> app loads DB -> using DB values, it changes the associated labels and all -> yay! \o/

And just one thing, that you might forget :D When I right click a object (in my case, a picture box or even a label), and select an option on context menu, how can I get an associated value from it and pass it to another form? Like... I've set Tag properties to a number in each picturebox. Now I want it to get into a variable to open a form with data based on that value.

Well, seems that I've asked a lot again! :D Sorry bout it, but I really want to learn and all by myself is being HELLISH hard haha :)

Thanks!

but how can I implement it on my code? I mean... load the app -> app loads DB -> using DB values, it changes the associated labels and all

Two ways to do it. First, is to load the app (empty form) -> load information about controls from the DB and create controls.

Second way should be easier. Use some fixed naming convention for controls. For example, labels' name 'firstLBL1', 'secondLBL2' and so on. In your DB refer to labels 'LBL1' and 'LBL2'. Now you have to use first code snippet to search for a control of type Label and which name ends with "LBL1".

Like... I've set Tag properties to a number in each picturebox. Now I want it to get into a variable to open a form with data based on that value.

You need to pass a sort of id-value to a form?
Here's what your details form needs:

Private _ID As Integer

Public Property ID As Integer
    Get
        Return _ID
    End Get
    Set(ByVal value As Integer)
        _ID = value
    End Set

End Property

Actually a normal property (because forms are just classes).

In the main form, you tag the controls:

PictureBox1.Tag = 3 ' Tag with some ID value

And finally you have to trap control's MouseClick event:

Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
    Dim oForm As Form2 ' Form2 is the type of your details form

    ' Create a form instance
    oForm = New Form2
    ' Set ID property
    oForm.ID = CInt(PictureBox1.Tag) ' Integer.TryParse() would be safer
    oForm.ShowDialog() ' Show the form
    oForm = Nothing ' Dispose form

End Sub

Just create an instance of your details form, which now has a property called ID. Set the property value and show the form. You can load the details from the form's Load event:

Private Sub LoadDetails()
    MsgBox("ID:" & _ID) ' DEBUG
End Sub

Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    LoadDetails() ' Call a sub to load details
End Sub

Instead of using property you can of course overload classes (i.e. form's) New constructor:

Public Class Form2

Public Sub New() ' Default constructor

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.

End Sub

Public Sub New(ByVal IDvalue As Integer) ' Overloaded constructor

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.
    _ID = IDvalue

End Sub

End Class

And the control's MouseClick event would be now:

Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
    Dim oForm As Form2 ' Form2 is the type of your details form

    ' Create a form instance
    oForm = New Form2(CInt(PictureBox1.Tag))
    oForm.ShowDialog() ' Show the form
    oForm = Nothing ' Dispose form

End Sub

HTH

Two ways to do it. First, is to load the app (empty form) -> load information about controls from the DB and create controls.

Second way should be easier. Use some fixed naming convention for controls. For example, labels' name 'firstLBL1', 'secondLBL2' and so on. In your DB refer to labels 'LBL1' and 'LBL2'. Now you have to use first code snippet to search for a control of type Label and which name ends with "LBL1".

The labels are fixed. Their names follow the pattern of "LabelX". When you say to refer to labels, you say use the IID as LBL1 and so, instead a number?

You need to pass a sort of id-value to a form?
Here's what your details form needs:

Private _ID As Integer

Public Property ID As Integer
    Get
        Return _ID
    End Get
    Set(ByVal value As Integer)
        _ID = value
    End Set

End Property

Actually a normal property (because forms are just classes).

In the main form, you tag the controls:

PictureBox1.Tag = 3 ' Tag with some ID value

And finally you have to trap control's MouseClick event:

Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
    Dim oForm As Form2 ' Form2 is the type of your details form

    ' Create a form instance
    oForm = New Form2
    ' Set ID property
    oForm.ID = CInt(PictureBox1.Tag) ' Integer.TryParse() would be safer
    oForm.ShowDialog() ' Show the form
    oForm = Nothing ' Dispose form

End Sub

Just create an instance of your details form, which now has a property called ID. Set the property value and show the form. You can load the details from the form's Load event:

Private Sub LoadDetails()
    MsgBox("ID:" & _ID) ' DEBUG
End Sub

Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    LoadDetails() ' Call a sub to load details
End Sub

Instead of using property you can of course overload classes (i.e. form's) New constructor:

Public Class Form2

Public Sub New() ' Default constructor

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.

End Sub

Public Sub New(ByVal IDvalue As Integer) ' Overloaded constructor

    ' This call is required by the designer.
    InitializeComponent()

    ' Add any initialization after the InitializeComponent() call.
    _ID = IDvalue

End Sub

End Class

And the control's MouseClick event would be now:

Private Sub PictureBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseClick
    Dim oForm As Form2 ' Form2 is the type of your details form

    ' Create a form instance
    oForm = New Form2(CInt(PictureBox1.Tag))
    oForm.ShowDialog() ' Show the form
    oForm = Nothing ' Dispose form

End Sub

HTH

But this calls a specific picturebox. I have 15 :P I know that I can simply copy and paste everything 15 times, but my goal is that, when you click any of the pictureboxes, it will read its associated number (of the picturebox you clicked) and then do the rest. And sorry if I'm not being clear or whatever, I'm a very beginner into VB.net and sometimes programming logic seems a bit hard to me :P

The labels are fixed. Their names follow the pattern of "LabelX". When you say to refer to labels, you say use the IID as LBL1 and so, instead a number?

Ok, then let the IID be just a number and use "Labelx" naming.

But this calls a specific picturebox.

Yes because I used only one.

The code in the details form needs just an ID. Now you "generalize" main form a bit. Actually using technique I already used earlier.

Private Sub PictureBox_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles PictureBox1.MouseClick, PictureBox2.MouseClick ' Add more picturebox MouseClicks separated with comma

    Dim oForm As Form2 ' Form2 is the type of your details form
    Dim ID As Integer

    'oForm = New Form2(CInt(PictureBox1.Tag)) ' Change this to handle any picturebox in a safer way

    ' Check that we get an integer
    If Integer.TryParse(CType(sender, PictureBox).Tag.ToString, ID) Then
        ' sender is a picbox with an integer in the Tag.
        ' You should actually check first that "CType(sender, PictureBox).Tag IsNot Nothing" to avoid possible object reference error
    Else
        ' Not an integer
        ' Handle the situation like you want and then exit
        Exit Sub
    End If

    ' Create a form instance
    oForm = New Form2(ID)
    oForm.ShowDialog() ' Show the form
    oForm = Nothing ' Dispose form

End Sub

Now you have one event handler for all the picture boxes. This uses overloaded New constructor but you can use ID-property version if you like.

HTH

Hm... I tried it, but with no sucess. When I add PictureBox1.MouseClick, PictureBox2.MouseClick to my code it gives me a error:

Handles clause requires a WithEvens variable defined in the containign type or one of its base types

What I'm doing wrong? This hole thing is being very hard. I think that I need to learn a bit more before continuing with this project.

But this calls a specific picturebox. I have 15 I know that I can simply copy and paste everything 15 times, but my goal is that, when you click any of the pictureboxes, it will read its associated number (of the picturebox you clicked) and then do the rest.

The point is that you don't need 15 identical event handlers. One single event handler can handle multiple controls.

it gives me a error:
Handles clause requires a WithEvens variable defined in the containign type or one of its base types

You just don't have control PictureBox1 or/and PictureBox2 in your form. Start a new project, drag and drop two picture boxes (check that their names are PictureBox1 and PictureBox2) to the form and copy/paste following code to the form:

Private Sub PictureBoxAll_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles PictureBox1.MouseClick, PictureBox2.MouseClick

    If TypeOf sender Is PictureBox Then
        MsgBox("I am PictureBox " & CType(sender, PictureBox).Name)
    End If

End Sub

Now run the app. You won't see empty picboxes but try to click them. Once you click a picture box you get the message box showing which box you clicked. This is just to show you how to handle multiple controls with a single event handler.

HTH

This hole thing is being very hard. I think that I need to learn a bit more before continuing with this project.

Who said that the programming would be easy? You are learning all the time by doing this project...

The point is that you don't need 15 identical event handlers. One single event handler can handle multiple controls.

So, if I only write PictureBox1 it will work for all 15 picture boxes?

You just don't have control PictureBox1 or/and PictureBox2 in your form. Start a new project, drag and drop two picture boxes (check that their names are PictureBox1 and PictureBox2) to the form and copy/paste following code to the form:

Private Sub PictureBoxAll_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) _
    Handles PictureBox1.MouseClick, PictureBox2.MouseClick

    If TypeOf sender Is PictureBox Then
        MsgBox("I am PictureBox " & CType(sender, PictureBox).Name)
    End If

End Sub

Now run the app. You won't see empty picboxes but try to click them. Once you click a picture box you get the message box showing which box you clicked. This is just to show you how to handle multiple controls with a single event handler.

HTH

Seems that this answers what I've asked a few lines above (: And just after reading this I've remembered that my pictureboxes have custom names. :$

Who said that the programming would be easy? You are learning all the time by doing this project...

I knew that it would be easy, just didn't tought that it would be so hard! :D

Everything is working now. I'll post the code later, because now I have to try another things. (:

Thanks! I'll mark it as solved as soon as I post the code.

Hey guys. Something went wrong. I've compilated the main functions on a dll, and then everything started to go wrong.

I still have the code of the main form, if someone is interested.

Imports System.Data.SQLite
Imports Funções.SQL 'my custom DLL

Public Class JanelaPrincipal

    'Carrega a janela principal
    Private Sub Janela_Principal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CarregaDados()
    End Sub

    'Gerencia os cliques nas PictureBoxes
    Private Sub PictureBoxAll_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Icon1.MouseClick, Icon2.MouseClick, Icon3.MouseClick, Icon4.MouseClick, Icon5.MouseClick, Icon6.MouseClick, Icon7.MouseClick, Icon8.MouseClick, Icon9.MouseClick, Icon10.MouseClick, Icon11.MouseClick, Icon12.MouseClick, Icon13.MouseClick, Icon14.MouseClick, Icon15.MouseClick

        If TypeOf sender Is PictureBox Then

            MsgBox("I am PictureBox " & CType(sender, PictureBox).Tag)
            TrocarÍcone._Tag = CType(sender, PictureBox).Tag
            TrocarÍcone.ShowDialog()
            CarregaDados()

        End If

    End Sub

    'Abre a janela que lista os jogos cadastrados
    Private Sub ListaCadastros_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListaCadastros.Click
        ListaJogosCadastrados.ShowDialog()
    End Sub

    'Carrega os dados
    Private Sub CarregaDados()
        Try
            'Define as variáveis
            Dim SQLconnect As New SQLite.SQLiteConnection()
            Dim SQLcommand As SQLiteCommand
            Dim Cadastro As String
            Dim Controles As Control
            Dim Imagens As Control
            Dim Tag As String
            Dim TagImagens As String


            'define string de conexão com banco de dados SQLite
            SQLconnect.ConnectionString = "Data Source=data\games.db3;Version=3;New=True;Compress=True;"

            'abre a conexão
            SQLconnect.Open()

            'cria um comando
            SQLcommand = SQLconnect.CreateCommand

            'define a instrução sql
            SQLcommand.CommandText = "SELECT * FROM Jogos ORDER By ID"

            'executa o comando e retorna um datareader
            Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()

            'percorre e exibe os dados
            While SQLreader.Read()

                'Lê o Cadastro
                Cadastro = SQLreader("Cadastro")

                'Procura por todos os controles na janela
                For Each Controles In Me.Controls
                    'Checa se o controle é uma Label
                    If TypeOf Controles Is Label Then
                        'Lê a tag do controle
                        Tag = DirectCast(Controles, Label).Tag
                        'Se a tag do controle for igual ao conteúdo do cadastro...
                        If Tag = Cadastro Then
                            '... nomear a label de acordo com o banco de dados
                            DirectCast(Controles, Label).Text = SQLreader("Nome")
                        End If
                    End If
                Next

                'Procura por todos os controles na janela
                For Each Imagens In Me.Controls
                    'Checa se o controle é uma PictureBox
                    If TypeOf Imagens Is PictureBox Then
                        'Lê a tag do controle
                        TagImagens = DirectCast(Imagens, PictureBox).Tag
                        'Se a tag do controle for igual ao conteúdo do cadastro...
                        If TagImagens = Cadastro Then
                            'Checa se a imagem no cadastro é vazia ou não
                            If SQLreader("Icone").Equals(System.DBNull.Value) Then
                                'Se for vazia, não renderiza nada
                                DirectCast(Imagens, PictureBox).Image = Nothing
                            Else
                                'Caso contrário, renderiza o ícone associado
                                DirectCast(Imagens, PictureBox).Image = BlobToImage(SQLreader("Icone"))
                            End If
                        End If
                    End If
                Next
            End While

            'Fecha a conexão
            SQLcommand.Dispose()
            SQLconnect.Close()

            'Gera a mensagem de erro
        Catch ex As Exception
            MsgBox("Erro ao acessar o SQLite: " & ex.Message)
        End Try
    End Sub
End Class

...and then everything started to go wrong

In programming things don't "start to go wrong", you get errors and error messages. Or the app doesn't work as you expected.

Do you get some error(message)? If you do, what is the exact error message.

As I said, I've compiled the functions into a DLL. Later, I decided to make thing easier, so I've changed a bit my functions DLL. I've renamed some functions and the DLL itself.

I've re-referenced it, but everytime I've tried to run or build the app, it kept asking me for the first DLL I've compiled. What went wrong?

As I said, I've compiled the functions into a DLL. Later, I decided to make thing easier, so I've changed a bit my functions DLL. I've renamed some functions and the DLL itself.

You have DLLs as separate projects you compile separately? You could use a single solution instead. Your app would be set as the start-up project and instead of referencing DLLs you would reference (DLL) projects in the solution. Now you could re-build all and there shouldn't come any reference errors.

You could check from Project -> <project name> Properties -> References-tab that everything is really ok i.e. paths etc. There's also "Unused References..."-button, check that too.

Anyway, you should re-build all from the beginning. If there's a references between DLLs, make sure that they get built in correct order.

HTH

Its been a while since I last posted here.

I've decided now to do not continue with this project. Mainly because I don't have time to learn everything I need, since now I got to go to college and still have to work :)

Also, I'm doing some extra-curricular activies that get almost all of my free time. When I learn a bit more I'll start all over again (;

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.