add text to a multiline textbox

tshukela.george 0 Tallied Votes 416 Views Share

every combobox selection is replaced with what a user has selected, I want it not to be replaced so that all seleced combobox can be printed

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox3.Text = "Welcome to lumga book shop sales database" & vbNewLine & vbNewLine & _
               "--------- --------- ------- ------------- ---------- --------" & vbNewLine & vbNewLine & _
   "Your cashier :  " & Sales_Log_in.txtUsername.Text & vbNewLine & vbNewLine & _
              "##############################################################" & vbNewLine & vbNewLine & _
              "DESCRIPTION OF ITEMS" & "          " & "Quantity " & "        " & "Price" & vbNewLine

        If ComboBox1.SelectedIndex = 1 Then
            TextBox3.Text = TextBox3.Text & vbNewLine & ComboBox1.SelectedItem & "             " & TextBox7.Text & "          " & Inventory1.price1.Text
        End If
        TextBox3.Text = TextBox3.Text & vbNewLine


        If ComboBox1.SelectedIndex = 2 Then
            TextBox3.Text = TextBox3.Text & vbNewLine & ComboBox1.SelectedItem & "             " & TextBox7.Text & "         " & Inventory1.price2.Text
        End If
        TextBox3.Text = TextBox3.Text & vbNewLine
        If ComboBox1.SelectedIndex = 3 Then
            TextBox3.Text = TextBox3.Text & vbNewLine & ComboBox1.SelectedItem & "            " & TextBox7.Text & "            " & Inventory1.price3.Text
        End If
        TextBox3.Text = TextBox3.Text & vbNewLine

        If ComboBox1.SelectedIndex = 4 Then
            TextBox3.Text = TextBox3.Text & vbNewLine & ComboBox1.SelectedItem & "           " & TextBox7.Text & "          " & Inventory1.price4.Text
        End If
        TextBox3.Text = TextBox3.Text & vbNewLine

        If ComboBox1.SelectedIndex = 5 Then
            TextBox3.Text = TextBox3.Text & vbNewLine & ComboBox1.SelectedItem & "             " & TextBox7.Text & "           " & Inventory1.price5.Text

        End If
        TextBox3.Text = TextBox3.Text & vbNewLine
Begginnerdev 256 Junior Poster

It seems as if you are storing prices in another form?

May I suggest storing prices into a database?

Something as simple as:

tblItems
ID | Int ID Not Null
Item | VarChar(50) Not Null
Price | Decimal(10,2) Not Null

The example given above would be using SQL Server (You can find SQL Express for free here.)

Then connect to the database and use the database to retreive the item values.

Here is an example of connecting to the database.

You can use set the selected value of the combobox to populate your fields with the data from the database.

tshukela.george 0 Newbie Poster

where do I have to put this

    tblItems
    ID | Int ID Not Null
    Item | VarChar(50) Not Null
    Price | Decimal(10,2) Not Null
Begginnerdev 256 Junior Poster

That would be an example of table structure.

You will need to design your tables accordingly.

Remember to normalize your tables to ward off any redundancy that is not necessary.

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.