8 Replies - 347 Views - Last Post: 22 July 2019 - 11:38 AM Rate Topic: -----

#1 Robbin101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 22-July 19

How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 04:35 AM

Public Class MainForm


    'one dimensional array

    Private sales(5) As Integer

    Private Sub MainForm_Load(sender As Object, e As System.EventArgs) Handles Me.Load

        idListBox.Items.Add("101")
        idListBox.Items.Add("112")
        idListBox.Items.Add("203")
        idListBox.Items.Add("301")
        idListBox.Items.Add("302")
        idListBox.SelectedIndex = 0

    End Sub



    

    Private Sub addButton_Click(sender As Object, e As System.EventArgs) Handles addButton.Click

        Dim salesamount As Integer
        Dim salesperson As Integer

        Integer.TryParse(saleTextBox.Text, salesamount)

        salesperson = idListBox.SelectedIndex

        'update the array
        sales(salesperson) += salesamount

       
    End Sub


    Private Sub createButton_Click(sender As Object, e As System.EventArgs) Handles createButton.Click

        Dim highsub As Integer = sales.Length - 1
        Dim total As Double
        

      
        'adds the total sales to the company total sales
        For i As Integer = 0 To highsub
            total += sales(i)
        Next

        

        'displays the results and all user input from textbox into the Label

        reLabel.Text = 
                       total.ToString

       


    End Sub

    Private Sub exitButton_Click(sender As Object, e As System.EventArgs) Handles exitButton.Click
        Me.Close()
    End Sub

   
End Class
:code:/>

This post has been edited by modi123_1: 22 July 2019 - 07:05 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: How do i display all items from listbox and textbox input in reLabel?

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15314
  • View blog
  • Posts: 61,413
  • Joined: 12-June 08

Re: How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 07:05 AM

Quote

all items from listbox and textbox input in reLabel

What do you mean?
Was This Post Helpful? 0
  • +
  • -

#3 Robbin101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 22-July 19

Re: How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 07:14 AM

I want when I press the create button,the list of id from the list box display along side the values I entered eg

"101" 2500
"112" 3000......
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15314
  • View blog
  • Posts: 61,413
  • Joined: 12-June 08

Re: How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 07:17 AM

Listboxes have a 'selected value' parameter. You can get the current value from that, and append the textbox data.. that would give you a string to stash in the label.
Was This Post Helpful? 0
  • +
  • -

#5 Robbin101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 22-July 19

Re: How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 08:03 AM

I get what you are saying about the select value but I am not sure what you mean by append the text box data. I am new to vb.net so I don't know much about it
Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15314
  • View blog
  • Posts: 61,413
  • Joined: 12-June 08

Re: How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 08:09 AM

So strings can be combined, right?

        Dim a As String = "hello"
        Dim b As String = "world"

        Console.WriteLine(a + b )


You can convert the 'selected value' from the listbox to a string (oddly enough .tostring), and use the + to mash that together with the textbox value.
Was This Post Helpful? 0
  • +
  • -

#7 Robbin101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 22-July 19

Re: How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 10:57 AM

View PostRobbin101, on 22 July 2019 - 04:35 AM, said:

Public Class MainForm


    'one dimensional array

    Private sales(5) As Integer

    Private Sub MainForm_Load(sender As Object, e As System.EventArgs) Handles Me.Load

        idListBox.Items.Add("101")
        idListBox.Items.Add("112")
        idListBox.Items.Add("203")
        idListBox.Items.Add("301")
        idListBox.Items.Add("302")
        idListBox.SelectedIndex = 0

    End Sub



    

    Private Sub addButton_Click(sender As Object, e As System.EventArgs) Handles addButton.Click

        Dim salesamount As Integer
        Dim salesperson As Integer

        Integer.TryParse(saleTextBox.Text, salesamount)

        salesperson = idListBox.SelectedIndex

        'update the array
        sales(salesperson) += salesamount

       
    End Sub


    Private Sub createButton_Click(sender As Object, e As System.EventArgs) Handles createButton.Click

        Dim highsub As Integer = sales.Length - 1
        Dim total As Integer
        Dim salesamount As Integer
        Dim id As String

Integer.TryParse(saleTextBox.Text, salesamount)


    id = Cstr(idListBox.Selecteditems)
      
        'adds the total sales to the company total sales
        For i As Integer = 0 To highsub
            total += sales(i)
        Next

        

        'displays the results and all user input from textbox into the Label

        reLabel.Text += id.ToString + "   " + salesamount.ToString + ControlChars.NewLine +
 total.ToString
                       

       


    End Sub

    Private Sub exitButton_Click(sender As Object, e As System.EventArgs) Handles exitButton.Click
        Me.Close()
    End Sub

   
End Class
:code:/>/>


I updated it and now I want to display the final total in the same label but idk how to get it to do that
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15314
  • View blog
  • Posts: 61,413
  • Joined: 12-June 08

Re: How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 11:10 AM

I have no clue where the 'final total' is, but you would do a similar thing. In your desired event to trigger the total, take the final results, convert to a string, and append to what ever.

It's the exact same concept.
Was This Post Helpful? 0
  • +
  • -

#9 Robbin101   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 22-July 19

Re: How do i display all items from listbox and textbox input in reLabel?

Posted 22 July 2019 - 11:38 AM

Ok thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1