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

  • SEARCH
  • Home
  • 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 7740707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:50:56+00:00 2026-06-01T08:50:56+00:00

From the MSDN Article I read I should be using the StringBuilder rather than

  • 0

From the MSDN Article I read I should be using the StringBuilder rather than concatenating a normal string. However I do not know why I get the following errer: “Variable ‘ShowString’ is used before it has been assigned a value. A null reference exception could result at runtime.”

The following code:

Dim ShowString As StringBuilder
    Dim ShowSort As StringBuilder
    'ShowString.
    ShowString.Append("POS,tdate,Product")
    '========Show Options==================
    If CheckBox1.Checked = True Then
        ShowString.Append(",tkey")
    End If
    If CheckBox2.Checked = True Then
        ShowString.Append(",Price")
    End If
    If CheckBox3.Checked = True Then
        ShowString.Append(",FID")
    End If
    '==========End Show Options============

    '=========Sort Options================
    If RadioButton1.Checked = True Then
        ShowSort.Append("tdate")
        If RadioButton8.Checked Then
            ShowSort.Append(" desc")
        End If
    End If
    If RadioButton2.Checked = True Then
        ShowSort.Append("tkey")
        If RadioButton8.Checked Then
            ShowSort.Append(" desc")
        End If
    End If
    '=======End Sort Options=============
    Dim sort As String = ShowSort.ToString
    Dim show As String = ShowString.ToString
    Try
        con.Open()
    Catch ex As Exception
        MessageBox.Show("Please contact support, there was a database error with the following message: " & ex.Message, "Cannot Connect", MessageBoxButtons.OK, MessageBoxIcon.Error)
    End Try
  • 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-06-01T08:50:58+00:00Added an answer on June 1, 2026 at 8:50 am

    You need to assign a StringBuilder object to the references:

    Dim ShowString As StringBuilder = New StringBuilder()
    

    Or:

    Dim ShowString As New StringBuilder()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Once I read an MSDN article that encouraged the following programming paradigm (its not
From the MSDN article on STAThread: Indicates that the COM threading model for an
I have been playing with the demo code from this msdn article by Jeffrey
From the ASP.Net Page Lifecycle article on MSDN : Although both Init and Load
From MSDN: The CancelWaitableTimer function does not change the signaled state of the timer.
From MSDN document i understand ( I am not sure,i understand perfectly ) :
I just read through a 2002 article on MSDN called Calling a .NET Component
I've already read the MSDN article about it. It seems internally it is the
Could you give a bullet list of practical differences/implication? I read relevant MSDN article,
I read the MSDN article on the topic. To quote: Because a service must

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.