-
Please Help
Hi
Please help me with this code
I would like to know how to make my l(length) always bigger than w(width).
eg: message box "Make Length bigger than width" and the 2 inputs, and 3 outputs = [blank]
Public Class Form1
Dim min, max As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim l, w, tl, r, x, rr As Integer
Call numbercheck(TextBox1.Text, 1, 30)
If numbercheck(TextBox1.Text, 1, 30) = True Then
l = TextBox1.Text
Else : MsgBox("Enter a number between 1 and 30 in the Length box") : TextBox1.Text = ""
End If
Call numbercheck(TextBox2.Text, 1, 20)
If numbercheck(TextBox2.Text, 1, 20) = True Then
w = TextBox2.Text
Else : MsgBox("Enter a number between 1 and 20 in the Width box") : TextBox2.Text = ""
End If
If w > l Then MsgBox("Make Length greater than Width") : TextBox1.Text = "" : TextBox2.Text = ""
'rolls'
r = (w / 5)
rr = Math.Ceiling(w / 5)
TextBox4.Text = r
'total length'
tl = (r * l)
TextBox3.Text = tl
'excess carpet'
x = (rr * 30) - tl
TextBox5.Text = x
TextBox3.Text = tl
TextBox4.Text = r
TextBox5.Text = x
End Sub
Function numbercheck(ByVal value, ByVal min, ByVal max)
If IsNumeric(value) = True Then
numbercheck = True
If value > max Then numbercheck = False
If value < min Then numbercheck = False
Else : numbercheck = False
End If
End Function
Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End Sub
End Class
-
Re: Please Help
Also:
My excess carpet (x) is wrong, I need help.
Here is the scenario:
Bob is a carpet layer. He needs a way to calculate how much carpet he needs to take with him to be able to cover the floor in a room. The carpet is supplied in rolls that are 5 metres wide and 30 metres long. Any excess width is discarded. This means that rooms that are wider than 5 metres need several strips of carpet.
The smallest area which Bob will carpet is 1m x 1m, the largest area he will carpet is 30m (the length of a roll) x 20m.
Bob always lays the carpet along the longer side of the room, even if it means more waste.
Bob charges for his carpet by the metre, so he only works in whole metre lengths. For example, even if Bob only needed 1.6 metres of carpet for the room, he would charge the customer for 2 metres because he has to discard the unused part of the metre.
Example
Imagine that Bob has to carpet a room that is 15m long and 11m wide.
Each roll of carpet is 30 metres long and 5 metres wide when it is unrolled.
Therefore, this room will need 3 strips of carpet. Each strip will be 15m long. Any excess width is discarded. The first two strips will be the full 5m wide, but the final strip will have to be cut so that it is only 1 metre wide.
At the moment, Bob has to draw diagrams (as shown in the example above) to work out how much carpet he needs, but a friend told him that he could get a computer program to work this out for him.
Bob has asked you to create a computer program that will tell him -
• how many metres of carpet he will need to cover a room,
• how many (full) rolls that will be,
• how many meters of full-width carpet he will have left on the last roll.
Bob has limited IT knowledge and would like this program to be easy to use, so he needs a user manual to explain how to use the program.
-
Re: Please Help
Your code is no Visual Basic 6 and, or Earlier
-
Re: Please Help
-
Re: Please Help
You are on the wrong section... It is Vb.Net... :)
Somebody please move this thread.... ;)