title: Use Methods and Functions to Prompt User for Inputting Data and Outputting Results of Calculations
body: <p>I am stuck on  a specific part of this VISUAL BASIC question. Here it is.</p>
  
  <pre><code>Write a program that is used to perform calculations on two numbers. 
  • The program should make use of the following methods: 
  1. Main() – Calls method getdata() 
  2. Getdata() – asks the user for data and type of calculation to perform then calls 
  the respective calculation method i.e. 
  – Add() 
  – Subtract() 
  – Multiply() 
  – Divide() 
  3. Displaydata() – called by the main method to display the results obtained  
  </code></pre>
  
  <p>This is what I have done so far............................................................</p>
  
  <pre><code>Module Module1
  
      Sub Main()
          Dim a, b, c As Integer
  
          Console.WriteLine("Please enter first number: ")
          a = Console.ReadLine()
  
          Console.WriteLine("Please enter second number: ")
          b = Console.ReadLine()
  
          Console.WriteLine("Which type of calculation would you like to perform? ")
          Console.WriteLine("1. Addition ")
          Console.WriteLine("2. Multiplication ")
          Console.WriteLine("3. Addition ")
          Console.WriteLine("4. Subtraction ")
  
          c = Console.ReadLine()
  
          If c = 1 Then
              add(a, b)
          Else
              If c = 2 Then
                  subtract(a, b)
              Else
                  If c = 3 Then
                      multiply(a, b)
                  Else
                      divide(a, b)
                  End If
              End If
          End If
      End Sub
  
      Sub add(ByVal y As Integer, ByVal z As Integer)
          Console.WriteLine("The sum of the two numbers is " &amp; y + z)
      End Sub
  
      Sub subtract(ByVal y As Integer, ByVal z As Integer)
          Console.WriteLine("The difference between the two numbers is " &amp; y - z)
      End Sub
  
      Sub multiply(ByVal y As Integer, ByVal z As Integer)
          Console.WriteLine("The product of the two numbers is " &amp; y * z)
      End Sub
  
      Sub divide(ByVal y As Integer, ByVal z As Integer)
          Console.WriteLine("The division of the two numbers is " &amp; y / z)
      End Sub
  
  End Module
  </code></pre>
  
  <p>As you can see, my main problem is to introduce the getData() and the displayData() functions to prompt for user input and display results. I have tried so many times but every time I get at least 25 errors and the program would not run. I would really appreciate any sort of assistance. Thank you in advance.</p>
  
  <p>And as asked, here is my failed attempt to insert the getData() and displayData() methods.</p>
  
  <pre><code>Module Module1
  
      Sub Main()
          Dim input As Integer
  
          input = Function getData()
          Function displayData()
          Console.WriteLine(c)
      End Function
  
      Function getData()
          Dim a, b, c As Integer
  
          Console.WriteLine("Please enter first number: ")
          a = Console.ReadLine()
          Return (a)
  
          Console.WriteLine("Please enter second number: ")
          b = Console.ReadLine()
          Return (b)
  
          Console.WriteLine("Which type of calculation would you like to perform? ")
          Console.WriteLine("1. Addition ")
          Console.WriteLine("2. Multiplication ")
          Console.WriteLine("3. Addition ")
          Console.WriteLine("4. Subtraction ")
  
          c = Console.ReadLine()
  
          If c = 1 Then
              add(a, b)
          Else
              If c = 2 Then
                  subtract(a, b)
              Else
                  If c = 3 Then
                      multiply(a, b)
                  Else
                      divide(a, b)
                  End If
              End If
          End If
  
          Return (c)
      End Function
  
      Sub add(ByVal y As Integer, ByVal z As Integer)
          Console.WriteLine("The sum of the two numbers is " &amp; y + z)
      End Sub
  
      Sub subtract(ByVal y As Integer, ByVal z As Integer)
          Console.WriteLine("The difference between the two numbers is " &amp; y - z)
      End Sub
  
      Sub multiply(ByVal y As Integer, ByVal z As Integer)
          Console.WriteLine("The product of the two numbers is " &amp; y * z)
      End Sub
  
  End Module
  </code></pre>