Visual Basic I/O

profileac14665

Directions: There are two parts (I and II) to this homework assignment.  Complete both in two separate files then submit both as your Module 4 Homework Assignment.

 

PART I:

 

Complete the following program exercises.  When you have completed the following exercises, compress the program folder and submit the .zip file.  These are all separate exercise, so you will have a separate file for each exercise.

 

Exercises from 5.1

 

Determine the output displayed when the button is clicked

 

Problem One:

 

Private Sub btnConvert_Click(…) Handles btnConvert.Click

     ‘Convert Celsius to Fahrenheit

     Dim temp As Double = 95

     txtOutput,Text = CStr (CtoF (temp) )

End Sub

Function CtoF (ByVal t As Double) As Double

     Return ( (9 / 5) * t) + 32

End Function

 

Problem Two:

 

Private Sub btnDisplay_Click(…) Handles btnDisplay.Click

     ‘Rule of 72

     Dim p As Double

     p = CDbl (txtPopGr.Text) ‘Population growth as a percent

     txtOutput.Text = “The population will double in “ &

                             DoubleTime(p) & “ years."

End Sub

 

Function DoublingTime(ByVal x As Double) As Double

     ‘Number of cars that can be parked

     Return 100 * x

End Function

 

Problem Three:

 

Private Sub btnDisplay_Click(…) Handles btnDisplay.Click

     Dim d As Date = #12/4/2011#

     txtOutput.Text = MonthAbbr(d)

End Sub

 

Funcion MonthAbbr(ByVal d As Date) As String

     Dim str As String = FormatDateTime(d, DateFormat.LongDate)

     Dim n As Integer = str.IndexOf(“ “)

     Return str.Substring(n + 1, 3)

End Function

 

Exercises from 5.2

 

Write a program that displays the output shown in a list box.  The last two lines of the output should be displayed by one or more Sub procedures using data passed by variables from an event procedure.

 

Problem One:

 

Assume that the following is displayed.

 

According to a 2008 survey of college freshman taken by the Higher

Education Research Institute:

16.7 percent said they intend to major in business.

1 percent said they intend to major in computer science.

 

Problem Two:

 

Assume that the label for txtBox reads “What is your favorite number?”, and the user types 7 into txtBox before btnDisplay is clicked.

 

The sum of your favorite number with itself is 14.

The product of your favorite number with itself is 49.

 

Problem Three:

 

Assume that the current date is 12/31/2010, the label for txtBox reads “What is your date of birth?”, and the user enters 2/3/1984 into txtBox before btnDisplay is clicked.

 

You are now 26 years old.

You have lived for 9824 days.

 

 

PART II:

 

Write a 2 page research paper (excluding the title page) on Function Procedures.

    • 6 years ago
    • 20
    Answer(2)

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      function_procedures_in_visual_basic.docx

    Purchase the answer to view it

    blurred-text
    NOT RATED