Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 340061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:34:52+00:00 2026-05-12T10:34:52+00:00

Not sure exactly what I need to do to make this work, so my

  • 0

Not sure exactly what I need to do to make this work, so my description may be lacking at first. Essentially I am writing a program launcher that recreates itself each time on load. It pulls the data regarding the tabs and buttons from an SQLite database and builds itself dynamically at run time. I get my problem when I pass the tab name through to the function that creates the buttons. I need the name to pull the right set of buttons from the database and I then tried to use the name to place the buttons on the right tab when I create them, but the debugger calls it a null reference because it doesn’t point correctly to the tabpage that I’m trying to make it point to (at least that is what I’m guessing). Any ideas on how to make this work right?

Private Sub CreateTabs()
    Dim SQLconnect As New SQLite.SQLiteConnection()
    Dim SQLcommand As SQLiteCommand
    SQLconnect.ConnectionString = "Data Source=" & sPath & "\dock.db;"
    SQLconnect.Open()
    SQLcommand = SQLconnect.CreateCommand
    SQLcommand.CommandText = "SELECT title FROM tabs"
    Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()
    Dim Tabs(25) As String
    Dim c As Integer = 1
    While SQLreader.Read()
        Tabs(c) = SQLreader(0)
        c = c + 1
    End While
    SQLcommand.Dispose()
    SQLconnect.Close()
    For i = 1 To UBound(Tabs)
        If Tabs(i) <> "" Then
            Launcher.TabPages.Add(Tabs(i))
            CreateButtons(Tabs(i))
        End If
    Next
End Sub

Private Sub CreateButtons(ByVal tab)
    Dim SQLconnect As New SQLite.SQLiteConnection()
    Dim SQLcommand As SQLiteCommand
    SQLconnect.ConnectionString = "Data Source=" & sPath & "\dock.db;"
    SQLconnect.Open()
    SQLcommand = SQLconnect.CreateCommand
    SQLcommand.CommandText = "SELECT id,name,path FROM buttons WHERE tab = '" & tab & "'"
    Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()
    While SQLreader.Read()
        For i = 1 To 9
            Dim NewButton(i) As Button
            If Not SQLreader(2) Is System.DBNull.Value Then
                Dim myIcon As System.Drawing.Icon = Icon.ExtractAssociatedIcon(SQLreader(2))
            End If
            Dim toolTip1 As ToolTip = New System.Windows.Forms.ToolTip(Me.components)
            Me.Controls(tab).tabpages.add(NewButton(i)) '<--this causes my problem
            'NewButton(i).Width = 32
            'NewButton(i).Height = 32
            'NewButton(i).Text = i
            'NewButton(i).Image = myIcon.ToBitmap
            'If Not SQLreader(1) Is System.DBNull.Value Then
            'toolTip1.SetToolTip(NewButton(i), SQLreader(1))
            'toolTip1.Active = True
            'End If
        Next
    End While
    SQLcommand.Dispose()
    SQLconnect.Close()
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T10:34:52+00:00Added an answer on May 12, 2026 at 10:34 am

    Thanks for the help, but I found my answer. Apparently I just needed to reference the index of the tab like so:

    Private Sub CreateTabs()
        Dim SQLconnect As New SQLite.SQLiteConnection()
        Dim SQLcommand As SQLiteCommand
        SQLconnect.ConnectionString = "Data Source=" & sPath & "\dock.db;"
        SQLconnect.Open()
        SQLcommand = SQLconnect.CreateCommand
        SQLcommand.CommandText = "SELECT title FROM tabs"
        Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()
        Dim Tabs(25) As String
        Dim c As Integer = 1
        While SQLreader.Read()
            Tabs(c) = SQLreader(0)
            c = c + 1
        End While
        SQLcommand.Dispose()
        SQLconnect.Close()
        For i = 1 To UBound(Tabs)
            If Tabs(i) <> "" Then
                Launcher.TabPages.Add(Tabs(i))
                CreateButtons(Tabs(i), i - 1)
            End If
        Next
    End Sub
    
    Private Sub CreateButtons(ByVal tab, ByVal TabIndex)
        Dim SQLconnect As New SQLite.SQLiteConnection()
        Dim SQLcommand As SQLiteCommand
        SQLconnect.ConnectionString = "Data Source=" & sPath & "\dock.db;"
        SQLconnect.Open()
        SQLcommand = SQLconnect.CreateCommand
        SQLcommand.CommandText = "SELECT id,name,path FROM buttons WHERE tab = '" & tab & "'"
        Dim SQLreader As SQLiteDataReader = SQLcommand.ExecuteReader()
        While SQLreader.Read()
            For i = 1 To 9
                Dim NewButton As New Button
                Launcher.TabPages.Item(TabIndex).Controls.add(NewButton)
                NewButton.Width = 32
                NewButton.Height = 32
                NewButton.Location = New Point(10 + (SQLreader(0) * 32) + 10, 10)
                NewButton.Text = SQLreader(0)
                If Not SQLreader(2) Is System.DBNull.Value Then
                    Dim toolTip1 As ToolTip = New System.Windows.Forms.ToolTip(Me.components)
                    Dim myIcon As System.Drawing.Icon = Icon.ExtractAssociatedIcon(SQLreader(2))
                    NewButton.Image = myIcon.ToBitmap
                    toolTip1.SetToolTip(NewButton, SQLreader(1))
                    toolTip1.Active = True
                End If
            Next
        End While
        SQLcommand.Dispose()
        SQLconnect.Close()
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure exactly how to word this question ... so edits are welcomed! Anyway
I'm not exactly sure how to ask this question really, and I'm no where
Coming from a desktop background I'm not sure exactly how to pass the exceptions
Not sure what exactly is going on here, but seems like in .NET 1.1
Not sure if this is possible or if I'm expressing correctly what I'm looking
Not sure how to ask a followup on SO, but this is in reference
Not sure if this is intended behavior or a bug or a wrong function
Not sure if the title is quite right for the question but I can't
Not sure if anyone listened to Hanselminutes episodes 134 and 135, but at the
Not sure what's going on here. I have a DateTime object, and when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.