Question
I need help with Visual Basic programming. This lab has 3 parts Part one uses overloaded methods Part two uses properties and inheritance Part 3
I need help with Visual Basic programming.
This lab has 3 parts
Part one uses overloaded methods
Part two uses properties and inheritance
Part 3 uses math class Part 1 Allow the user add 2 integers from separate textboxes. Allow the user to optionally add a third number from a third textbox. If an if statement to determine if 3rd textbox is used Use a class to hold the calculate methods Name the class part1Class Name the method Add Instantiate it globally
Hint: Dim myClassVB As part1Class = New part1Class()
Show the results in a messagebox when the user clicks a button labeled Add Numbers.
Overload the method in the class to allow strings instead of integers. Allow the user to optionally add a third string from a third textbox. Show the results in a messagebox when the user clicks a button labeled Add Strings. Use a class that utilizes an overloaded method Add a button that loads a second form: Hint (method signatures only you must figure out rest):
Public Function Add(num1 As Integer, num2 As Integer) As Integer
Public Function Add(num1 As Integer, num2 As Integer, num3 As Integer) As Integer
Public Function Add(s1 As String, s2 As String) As String
Public Function Add(s1 As String, s2 As String, s3 As String) As String
Hint 2: Parts missing: Dim a As Integer = CType(textBox1.Text, Integer)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
If textBox3.Text <> "" Then
Dim c As Integer = CType(xxxxxxxxxxxxxxxxxxx)
MessageBox.Show(myClassVB.Add(a, b, c).ToString())
Else
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
End If MessageBox.Show(myClassCS.Add(a, b, c).ToString());
}
else
{
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}
Hint for Add Strings: If textBox3.Text <> "" Then
MessageBox.Show(myClassVB.Add(textBox1.Text, textBox2.Text, textBox3.Text)) Else
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
End If Part 2 Add another form Add a class Name it part2Class It should have 2 private instance variables _num1 and _num2 Create a public property for each Create a public overridable method called calculate that adds these two properties together and returns the result Hint: Public Property Num1 Public
Property Num2
Public Overridable Function Calculate() As Integer
Return Num1 + Num2
End Function
Create another class that inherits from the first class in the part Name it part2bClass Override the calculate method so that it multiplies the numbers instead of adding them Hint: Inherits part2Class Public Overrides Function Calculate() As Integer
Return Num1 * Num2
End Function In your Windows program(second form) create an interface that accepts two numbers from textboxes, passes them to part2Class.calculate method and outputs the result to a messagebox
HINT: Set the properties first and then call the calculate method from the part2Class class Add another button that calls the overridden method from the part2bClass class and outputs to a messagebox You will have two classes First class will have 2 private member variables 2 properties 1 overridable method called calculate Second class will have 1 method that overrides the method in the first class called calculate Add a button that loads a third form and goes back to first form Part 3 o In this form ask the user for two sides of a right angle triangle. A and B o Use a method in a class to figure out the hypotenuse of the triangle o Remember: A2+B2=C2 o Use the Math class to help you o Use the line tool from the Visual basic Power Pack to draw a right angle triangle You program should have the ability to go to any part from any form
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started