Ask Experts Questions for FREE Help !
Ask
    littleivyle's Avatar
    littleivyle Posts: 3, Reputation: 1
    New Member
     
    #1

    Jan 3, 2010, 08:07 PM
    visual basics how many rolls to cover a wall
    I have to create an application that calculates the number of wallpaper rolls to cover a wall. I also have to use one or more independent sub or function procedures. So far I have this but it keeps telling me I can't divide by zero.
    'declare variables
    Dim WallWidth As Integer 'width of wall
    Dim WallHeight As Integer 'height of wall
    Dim RollLength As Integer ' length of wallpaper roll
    Dim RollWidth As Integer ' width of wallpaper roll
    Dim areawall As Integer
    Dim area As Integer
    Dim NumofRoll As Integer 'number of rolls needed
    Dim totroll As Integer

    'Text box is numeric
    If txtwidthwall.Text <> "" Then
    'assign text box
    If IsNumeric(txtwidth.Text) Then
    WallWidth = Convert.ToInt32(txtwidth.Text)
    ElseIf IsNumeric(txtheight.Text) Then
    WallHeight = Convert.ToInt32(txtheight.Text)
    ElseIf IsNumeric(txtlengthwall.Text) Then
    RollLength = Convert.ToInt32(txtlengthwall.Text)
    ElseIf IsNumeric(txtwidthwall.Text) Then
    RollWidth = Convert.ToInt32(txtwidthwall.Text)

    Else
    MessageBox.Show("Please enter number.", _
    "Wallpaper", MessageBoxButtons.OK, _
    MessageBoxIcon.Information, _
    MessageBoxDefaultButton.Button1)

    End If
    areawall = WallWidth * WallHeight
    Call Arearoll(RollLength, RollWidth, Area)
    totroll = areawall / area

    End If
    Me.lbltotal.Text = Convert.ToString(totroll)






    End Sub
    Private Sub Arearoll(ByVal length As Integer, ByVal width As Integer, ByRef area As String)
    'calculates the number of rolls
    area = length * width
    InfoJunkie4Life's Avatar
    InfoJunkie4Life Posts: 1,409, Reputation: 81
    Ultra Member
     
    #2

    Jan 4, 2010, 08:29 AM

    You never put a value in your "area" variable, but you defined it as an integer. This will cause it to be equal to zero until otherwise stated. The "length" and "width" variables were never declared, or assigned a value, so your Sub does nothing. You can't divide by zero (at least not in VB). Thus areawall / area = nonsense.
    InfoJunkie4Life's Avatar
    InfoJunkie4Life Posts: 1,409, Reputation: 81
    Ultra Member
     
    #3

    Jan 4, 2010, 08:29 AM
    Just from this glance, it seems like you're over complicating this task.
    littleivyle's Avatar
    littleivyle Posts: 3, Reputation: 1
    New Member
     
    #4

    Jan 5, 2010, 04:15 PM

    so if I don't do a separate sub function and just solve the area in the calculate sub would I put the area intger and change that to a string variable
    InfoJunkie4Life's Avatar
    InfoJunkie4Life Posts: 1,409, Reputation: 81
    Ultra Member
     
    #5

    Jan 5, 2010, 06:33 PM

    totroll = areawall / area

    instead

    totroll = areawall / Val(area)

    As long as area doesn't contain any other characters.

    Why is it a string value anyway?
    littleivyle's Avatar
    littleivyle Posts: 3, Reputation: 1
    New Member
     
    #6

    Jan 5, 2010, 08:30 PM

    No I think that should work! Thanks so much!

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Home made Rolls (Yeast) [ 1 Answers ]

Anyone have any ideas on how to get my yeast rolls to market. These are homemade yeast rolls. Every time I make them people want to buy them. Everyone keeps telling me to get these in the store. Any suggestions on how to sell the recipe or manufacture to get into the market place.

Cover paneling with wall paper [ 3 Answers ]

:o I have paneling on my walls from the 70's. I'd like to fill the spaces, cracks and holes then cover with wallpaper. I've been told to fill the spaces, cracks and holes with something that doesn't shrink. I know very little about this. Anyone have a suggestion as to what product I should use?

Sausage rolls/Bero cookbook [ 3 Answers ]

I am married to a Yorkshireman who has lived in the US for two years. I am desperate to have a recipe for sausage rolls and any other "Yorkshire" recipes. I also have tried to find a way to get a Bero cookbook with no success. Help please!


View more questions Search