All these New Object()s are identical (and in fact, much longer!) How do I declare a single instance then reuse it in each ComboBox .Items.AddRange()? I am using Visual Studio 2008/Visual Basic.

verticalBarComboBox.Items.AddRange(New Object() {" single space", "- hyphen", " -  <single space>hyphen<single space>", "` open single quote", "=", "~", "!"})
 backSlashComboBox.Items.AddRange(New Object() {" single space", "- hyphen", " -  <single space>hyphen<single space>", "` open single quote", "=", "~", "!"})
 colonComboBox.Items.AddRange(New Object() {" single space", "- hyphen", " -  <single space>hyphen<single space>", "` open single quote", "=", "~", "!"})
 quoteComboBox.Items.AddRange(New Object() {" single space", "- hyphen", " -  <single space>hyphen<single space>", "` open single quote", "=", "~", "!"})

Thanks!

As RamyMahrous said use an array. If you deceide to add or remove anything later you only need to do it in one place.

Dim ary As String() = {" single space", "- hyphen", " -  <single space>hyphen<single space>", "` open single quote", "=", "~", "!"}

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        verticalBarComboBox.Items.AddRange(ary)
        backSlashComboBox.Items.AddRange(ary)
        colonComboBox.Items.AddRange(ary)
        quoteComboBox.Items.AddRange(ary)
    End Sub

Thanks to both!

As this is my first VB project, I needed the code snippet.

This question has already been answered. Start a new discussion instead.