Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

VS 2010 [RESOLVED] vb loop issue - for each??

$
0
0
OK I have a calculator - to work out flooring required.

This is an assignment so really looking for guidance on what to do rather than an answer.

I've done 95% of the calc and its functions.

There is a datagridview on a form for outputting records.

one of the requirements for 5% of the total mark is to output in the dgv on a separate form the total area of each floor required for each floortype.

I have this structure in a module:

Code:

Module Module1
    Public Structure flooring
        Dim lngth As Integer
        Dim wdth As Integer
        Dim floortype As String
    End Structure

    Public myFlooring As flooring
    Public colFloor As New Collection


End Module


The user inputs length - width and flooring type (limited to four types)
on this particular output i need to find each occurrence of a floortype ie beech add the lengths together for each occurrence of beech. then the same for width.
Then I need to multiply total length of beech * total width of beech and output this onto a datagridview.

I have almost no idea what I'm doing.. Think i missed a class or something lol

this is nowhere near correct I know, I've probably been closer but couldn't see it so am just writing random crap now lol

Code:

    Private Sub btnTotals_Click(sender As System.Object, e As System.EventArgs) Handles btnTotals.Click
        dgvFlooring.Rows.Clear()
        dgvFlooring.Columns.Clear()
        dgvFlooring.Columns.Add("FloorType", "Floor Type")
        dgvFlooring.Columns.Add("Total", "Total")

        Dim beechtotalLength As Integer
        Dim beechtotalWidth As Integer
        Dim beechtotalArea As Integer

        Dim Bluetotalwidth As Integer
        Dim bluetotallength As Integer
        Dim bluetotalarea As Integer

        Dim floor As flooring


        For Each quote As Object In colFloor


            If CStr(floor.floortype) = "Beech" Then
                beechtotalLength += floor.lngth
                beechtotalWidth += floor.wdth
            End If

        Next

        beechtotalArea = beechtotalLength * beechtotalWidth

        dgvFlooring.Rows.Add("blue", bluetotalarea.ToString)
        dgvFlooring.Rows.Add("Beech", beechtotalArea.ToString)

    End Sub


so I'm looking for in dgv

say there are 3 entries of beech floor
floortype beech length 6 width 6
floortype beech length 2 width 8
floortype beech length 6 width 10

i need to have a total length for beech 6+2+6
and a total width for beech 6+8+10

then as output a total area in the dgv (total length * total width)
ie:

Beech - 336
blue - 447
etc..

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>