none
Need help with project i am working on RRS feed

  • Question

  • Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            Dim Diffproduct1 As Integer = 0
            Dim boxcount1 As Integer = 0
            Dim palletnumber1 As Integer = 0
            Dim totalsum As Double = 0
            Dim total As Decimal
    
    
            ProgressBar1.Minimum = palletnumber1
            ProgressBar2.Minimum = boxcount1
    
            Randomize()
            box1 = 1
            pal1 = 1
            diff1 = 1
    
            For Diffproduct1 = 0 To Form2.ListView2.Items.Count - 2
    
    
    
    
    
    
                For palletnumber1 = 1 To Form2.ListView2.Items(0).SubItems(3).Text()
    
    
    
                    Dim item6 As New ListViewItem(Form1.TextBox1.Text & Form2.ListView2.Items(0).SubItems(0).Text() & pal1.ToString("00000"))
    
    
    
                    ListView1.Items.Add(item6)
    
                    ListView2.Items.Clear()
    
    
                    For boxcount1 = 1 To Form2.ListView2.Items(0).SubItems(2).Text()
    
    
                        Dim item5 As New ListViewItem("Box#:" & Form1.TextBox1.Text & box1.ToString("00000"))
                        Dim rn As New Random
    
    
    
                        item5.SubItems.Add(Form2.ListView2.Items(0).SubItems(0).Text())
                        item5.SubItems.Add(rn.Next(Form2.ListView1.Items(0).SubItems(2).Text(), (Form2.ListView1.Items(0).SubItems(3).Text())) & "." & (Format(rn.Next(0, 99), "00")))
    
                        ListView2.Items.Add(item5)
    
    
    
                        total = total + ListView2.Items(0).SubItems(2).Text()
    
    
    
    
                        box1 = box1 + 1
    
                        TextBox1.Text = Format(total, "#,##0.00")
    
    
                        ProgressBar2.Maximum = box1
                        ProgressBar2.Value = box1
    
    
    
    
    
                    Next
                    total = 0
                    pal1 = pal1 + 1
                    ProgressBar1.Maximum = pal1
                    ProgressBar1.Value = pal1
    
    
    
                Next
                diff1 = diff1 + 1
    
            Next
    
    
        End Sub
    ok the problem I am having is if you look at the production form bottom list view shows 2 different products , when you look at produce pallet form it only shows 1 product being produced.  now I add the forms to show what I am working on to give some idea to what is going on and the code block that this sits in
    Friday, February 15, 2019 3:56 PM

Answers

  • Alex that didn't fix the problem but I found a way to do the job and to write it to a text file on top of it
    Dim boxcount1 As Integer = 0
            Dim palletnumber1 As Integer = 0
            Dim totalsum As Double = 0
            Dim total As Decimal
            Dim pallet As String
    
            ProgressBar1.Minimum = palletnumber1
            ProgressBar2.Minimum = boxcount1
    
    
    
    
    
            For Each i As ListViewItem In Form2.ListView2.Items
    
                For palletnumber1 = 1 To Form2.ListView2.Items(0).SubItems(3).Text()
    
                    Dim item6 As New ListViewItem(Form1.TextBox1.Text & Form2.ListView2.Items(0).SubItems(0).Text() & pal1.ToString("00000"))
    
                    pallet = (Form1.TextBox1.Text & Form2.ListView2.Items(0).SubItems(0).Text() & pal1.ToString("00000") & ".txt")
    
    
                    Dim ts As New IO.StreamWriter("C:\Pallets\" & pallet, False, System.Text.Encoding.UTF8)
    
                    ListView1.Items.Add(item6)
    
                    ListView2.Items.Clear()
    
                    For boxcount1 = 1 To Form2.ListView2.Items(0).SubItems(2).Text()
    
                        Dim item5 As New ListViewItem("Box#:" & Form1.TextBox1.Text & box1.ToString("00000"))
                        Dim rn As New Random
                        Randomize()
                        ts.WriteLine(("Box#:" & Form1.TextBox1.Text & box1.ToString("00000") & vbTab & Form2.ListView2.Items(0).SubItems(0).Text() & vbTab & (rn.Next(Form2.ListView1.Items(0).SubItems(2).Text(), (Form2.ListView1.Items(0).SubItems(3).Text())) & "." & (Format(rn.Next(0, 99), "00")))))
    
    
                        item5.SubItems.Add(Form2.ListView2.Items(0).SubItems(0).Text())
                        item5.SubItems.Add(rn.Next(Form2.ListView1.Items(0).SubItems(2).Text(), (Form2.ListView1.Items(0).SubItems(3).Text())) & "." & (Format(rn.Next(0, 99), "00")))
    
                        ListView2.Items.Add(item5)
    
                        total = total + ListView2.Items(0).SubItems(2).Text()
    
                        box1 = box1 + 1
    
                        TextBox1.Text = Format(total, "#,##0.00")
    
                        ProgressBar2.Maximum = box1
                        ProgressBar2.Value = box1
    
                    Next
    
                    ts.WriteLine("Weight:" & vbTab & (Format(total, "#,##0.00")))
    
                    total = 0
                    pal1 = pal1 + 1
                    ProgressBar1.Maximum = pal1
                    ProgressBar1.Value = pal1
    
                    ts.Close()
    
    
                Next
    
    
    
    
                Form2.ListView2.Items.Remove(i)
            Next
            Timer1.Start()
    

    • Marked as answer by Dan Sprouse Thursday, February 21, 2019 6:43 PM
    Thursday, February 21, 2019 6:41 PM

All replies

  • Hi,

    try to fix the code:

     Dim item6 As New ListViewItem(Form1.TextBox1.Text & Form2.ListView2.Items(0).SubItems(0).Text() & pal1.ToString("00000"))

     Dim item6 As New ListViewItem(Form1.TextBox1.Text & Form2.ListView2.Items(Diffproduct1).SubItems(0).Text() & pal1.ToString("00000"))

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 18, 2019 1:46 AM
  • Alex that didn't fix the problem but I found a way to do the job and to write it to a text file on top of it
    Dim boxcount1 As Integer = 0
            Dim palletnumber1 As Integer = 0
            Dim totalsum As Double = 0
            Dim total As Decimal
            Dim pallet As String
    
            ProgressBar1.Minimum = palletnumber1
            ProgressBar2.Minimum = boxcount1
    
    
    
    
    
            For Each i As ListViewItem In Form2.ListView2.Items
    
                For palletnumber1 = 1 To Form2.ListView2.Items(0).SubItems(3).Text()
    
                    Dim item6 As New ListViewItem(Form1.TextBox1.Text & Form2.ListView2.Items(0).SubItems(0).Text() & pal1.ToString("00000"))
    
                    pallet = (Form1.TextBox1.Text & Form2.ListView2.Items(0).SubItems(0).Text() & pal1.ToString("00000") & ".txt")
    
    
                    Dim ts As New IO.StreamWriter("C:\Pallets\" & pallet, False, System.Text.Encoding.UTF8)
    
                    ListView1.Items.Add(item6)
    
                    ListView2.Items.Clear()
    
                    For boxcount1 = 1 To Form2.ListView2.Items(0).SubItems(2).Text()
    
                        Dim item5 As New ListViewItem("Box#:" & Form1.TextBox1.Text & box1.ToString("00000"))
                        Dim rn As New Random
                        Randomize()
                        ts.WriteLine(("Box#:" & Form1.TextBox1.Text & box1.ToString("00000") & vbTab & Form2.ListView2.Items(0).SubItems(0).Text() & vbTab & (rn.Next(Form2.ListView1.Items(0).SubItems(2).Text(), (Form2.ListView1.Items(0).SubItems(3).Text())) & "." & (Format(rn.Next(0, 99), "00")))))
    
    
                        item5.SubItems.Add(Form2.ListView2.Items(0).SubItems(0).Text())
                        item5.SubItems.Add(rn.Next(Form2.ListView1.Items(0).SubItems(2).Text(), (Form2.ListView1.Items(0).SubItems(3).Text())) & "." & (Format(rn.Next(0, 99), "00")))
    
                        ListView2.Items.Add(item5)
    
                        total = total + ListView2.Items(0).SubItems(2).Text()
    
                        box1 = box1 + 1
    
                        TextBox1.Text = Format(total, "#,##0.00")
    
                        ProgressBar2.Maximum = box1
                        ProgressBar2.Value = box1
    
                    Next
    
                    ts.WriteLine("Weight:" & vbTab & (Format(total, "#,##0.00")))
    
                    total = 0
                    pal1 = pal1 + 1
                    ProgressBar1.Maximum = pal1
                    ProgressBar1.Value = pal1
    
                    ts.Close()
    
    
                Next
    
    
    
    
                Form2.ListView2.Items.Remove(i)
            Next
            Timer1.Start()
    

    • Marked as answer by Dan Sprouse Thursday, February 21, 2019 6:43 PM
    Thursday, February 21, 2019 6:41 PM