r/visualbasic • u/uni_and_internet • Feb 24 '16
I need to generate 3 random numbers within a range (0<X<10), and assign those numbers to variables, all inside a sub-procedure. Every attempt at researching "making a random number" brings me to generating a number by pressing a button. Can anyone help me with this problem?
This is the full text of my problem, for added context.
Triangle inequality theorem states that the sum of two sides of a triangle must be greater than the third side. If this is true for all three combinations, then you will have a valid triangle.
Write a VB application that will randomly generate the sides of 5 triangles and calculate the perimeter and area of each triangle. When the user clicks btnTrianglesbutton, it should complete the following tasks:
(a)Call getTriangleSides(...) sub-procedure within click event procedure of btnTriangles. This procedure will randomly generate three sides of a triangle.Each side of a triangle must be greater than zero and less than 10.
(b)Call getProperties(...) sub-procedure within click event procedure of btnTriangles. This procedure will calculate the perimeter and area of the triangle.
(c)Display sides of 5 triangles with perimeter and area in tabular format within click event procedure of btnTriangles. Format numbers to one decimal place.Add clear button in your application.
3
u/JakDrako Feb 24 '16
Assuming VB.Net, you can use the "System.Random" object to create your random numbers. Here is a short example: