none
how to export values from listboxes to excel RRS feed

  • Question

  • THE CODE BELOW ONLY EXPORTS THE TITLES OF THE FIVE LISTBOXES TO EXCEL
    But I need all the numbers in the listboxes to get exported to excel as well
    
    I need help on the coding to export the numbers IN THE FIVE LISTBOXES TO EXCEL AS WELL 
    
    I NEED HELP ON THE CODING TO EXPORT THE VALUES FROM THE LISTBOXES TO EXCEL

    Public Class Form4
        Dim count As Integer
        Dim Total As Integer
        Dim NewJ, NewA, NewS As Integer
    
    
        Private Sub Form4_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            ListBox1.items.add(0)
            listbox2.items.add(Form2.P_Juveniles)
            listbox3.items.add(Form2.P_Adults)
            listbox4.items.add(Form2.P_Seniles)
            Listbox5.Items.Add(Form2.P_Juveniles + Form2.P_Adults + Form2.P_Seniles)
    
            For f = 1 To Form2.New_Generations
                NewJ = Form2.P_Adults * Form2.B_rate
                NewA = Form2.P_Juveniles * Form2.S_Juveniles
                NewS = (Form2.P_Adults * Form2.S_Adults) + (Form2.P_Seniles * Form2.S_Seniles)
                Total = NewJ + NewA + NewS
                ' brackets- more efficient
    
                Form2.P_Juveniles = NewJ
                Form2.P_Adults = NewA
                Form2.P_Seniles = NewS
    
                Listbox1.Items.Add(f)
                Listbox2.Items.Add(NewJ)
                Listbox3.Items.Add(NewA)
                Listbox4.Items.Add(NewS)
                Listbox5.Items.Add(Total)
    
            Next
    
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Form5.Focus()
            Form5.Show()
            Me.Hide()
    
        End Sub
    
    
    
        Private Sub Generation_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Listbox1.SelectedIndexChanged
    
    
        End Sub
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Form1.Focus()
            Form1.Show()
            Me.Hide()
    
        End Sub
    End Class


    • Edited by anonymous_fl Thursday, February 16, 2017 5:50 PM
    Thursday, February 16, 2017 5:46 PM