Write the code that would perform the following conditions:
- Write a function that will return the area of a rectangle.
PrivateFunction getArea(ByVal sideA AsDouble, ByVal sideB AsDouble) AsDouble
Return (sideA * sideB)
EndFunction
- Write a function that will return the absolute value of a number.
PrivateFunction getAbsoluteValue(ByVal num AsDouble) AsDouble
If (num < 0) Then
Return -num
Else
Return num
EndIf
EndFunction
- Write a function that will return the letter grade when passed a test score, where a score between 90 and 100 is an A, etc.
PrivateFunction getAbsoluteValue(ByVal score AsDouble) AsString
If (score >= 90 And score <= 100) Then
Return"A"
ElseIf (score >= 80) Then
Return"B"
ElseIf (score >= 70) Then
Return"C"
ElseIf (score >= 60) Then
Return"D"
Else
Return"F"
EndIf
EndFunction
- Write a function that will return a full name string when passed a first name string, a middle name or initial string, and a last name string. If the middle initial is blank, there should be only one space between the first and last name.
PrivateFunction getAbsoluteValue(ByVal fName AsString, ByVal mName AsString, ByVal lName AsString) AsString
If mName = ""Then
Return fName & " " & lName
Else
Return fName & " " & mName & " " & lName
EndIf
EndFunction
- Write a sub procedure that enables 3 text boxes on the form when a checkbox is enabled and disables the 3 textboxes when a checkbox is disabled.
PrivateSub enaleDisableTextBoxes()
If CheckBox1.Enabled = TrueThen
TextBox1.Enabled = True
TextBox2.Enabled = True
TextBox3.Enabled = True
ElseIf CheckBox1.Enabled = FalseThen
TextBox1.Enabled = False
TextBox2.Enabled = False
TextBox3.Enabled = False
EndIf
EndSub
Video Bonanza Part five Visual Basic 2005
Modify the case study project from the previous Video Bonanza to use menus and a function procedure. Refer to the previous Video Bonanza for project specifications.
Use a function procedure to calculate the rental fee based on the type of video.
The Help menu About option should display a message box with information about the program and the programmer, The Color option should change the background color of the form; the font changes can change the control of your choice.
Menu:
Optional extra: Set keyboard shortcuts for the menu commands.
This is the previous specs from Video Bonanza Part 4 Visual Basic 2005
Design and code a project to calculate the amount due for rentals. Movies maybe in VHS (videotape) format or DVD format. Videotapes rent for $1.80 each and DVDs rent for $2.50. New releases are $3 for DVD and $2 for videotape.
On the form include a text box to input the movie title and radio buttons to indicate whether the movie is in DVD or videotape format. Use one check box to indicate whether the person is a member; members receive a 10 percent discount. Another check box indicates a new release.
Use buttons for Calculate, Clear for Next Item, Order Complete, Summary, and Exit. The Calculate button should display the item amount and add to the subtotal. The Clear for Next Item clears the check box for new releases, the movie title, and the radio buttons; the member check box cannot be changed until the current order is complete. Include validation to check for missing data. If the user clicks on the Calculate button without first entering the movie title and selecting the movie format, display a message box.
For the Order Complete button, first confirm the operation with the user and clear the controls on the form for a new customer.
The Summary button displays the number of customers and the sum of the rental amounts in a message box. Make sure to add to the customer count and rental sum for each customer order.