Problem 2 : Business Travel Expense

jayace

Member
Joined
Aug 22, 2011
Messages
6
Programming Experience
Beginner
this is the problem.
Write a program to generate a business travel expense attachment for an income-tax return. The program should request as input the name of the organization visited, the date and location of the visit, and the expenses for meals and entertainment, airplane fare, lodging, and taxi fares. (Only 50% of the expenses for meals and entertainment are deductible.) The output is displayed in a list box that becomes visible when the button is clicked. Sub procedures should be used for the input and output.

sample input and output can be shown here: Book reviews: An Introduction to Programming Using Visual Basic 2005. Chapter 4 Programming Projects

my error is "too many argument in Public Sub InputValues(.......)"
my code is this:
i used indexof because for example the user inputted a date with a year then the output will ignore the year. only the month and specific date will appear.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b, c, d, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String
Dim duration As String
InputValues(a, b, c, d, f, g, h)
CalculateNumbers(a, b, c, d, g)
Results(a, b, c, d, f, g, h)

duration = TextBox2.Text

End Sub

Sub InputValues(ByRef orgvisit As String, ByRef locate As String, ByRef expformealsandent As Double, ByRef airlinefare As Double, ByRef expforlodging As Double, ByRef taxifare As Double)

orgvisit = TextBox1.Text
'duration = TextBox2.Text
locate = TextBox3.Text
expformealsandent = CDbl(TextBox4.Text)
airlinefare = CDbl(TextBox5.Text)
expforlodging = CDbl(TextBox6.Text)
taxifare = CDbl(TextBox7.Text)

End Sub

Function FirstDate(ByVal duration As String) As String
Dim Firstcomma As Integer

Firstcomma = duration.IndexOf(",")

Return duration.Substring(0, Firstcomma)

End Function

Sub CalculateNumbers(ByVal airlinefare As Double, ByVal expforlodging As Double, ByVal taxifare As Double, ByRef total1 As Double, ByRef total2 As Double)

total1 = airlinefare + expforlodging + taxifare
total2 = total1 / 2

End Sub

Sub Results(ByVal orgvisit As String, ByVal expformealsandent As Double, ByVal airlinefare As Double, ByVal expforlodging As Double, ByVal taxifare As Double, ByVal total1 As Double, ByVal total2 As Double)
Dim frmstr As String = "{0,-10}{1,18}"
With ListBox1.Items
.Clear()
.Add("Business Travel Expense")
.Add(String.Format("Trip to attend meeting of " & orgvisit & "", orgvisit))
'.Add("")
.Add(String.Format(frmstr, "Meals and Entertainment", FormatCurrency(expformealsandent, 2)))
.Add(String.Format(frmstr, "Airplane Fare", FormatCurrency(airlinefare, 2)))
.Add(String.Format(frmstr, "Lodging", FormatCurrency(expforlodging, 2)))
.Add(String.Format(frmstr, "Taxi Fares", FormatCurrency(taxifare, 2)))

.Add("===========================================================")
.Add(String.Format(frmstr, "Total other than meals and entertainment", FormatCurrency(total1, 2)))
.Add(String.Format(frmstr, "50% of meals and entertainment", FormatCurrency(total2, 2)))
End With
End Sub

End Class
 
my error is "too many argument in Public Sub InputValues(.......)"
Sub InputValues(ByRef orgvisit As String, ByRef locate As String, ByRef expformealsandent As Double, ByRef airlinefare As Double, ByRef expforlodging As Double, ByRef taxifare As Double)
6 parameters
InputValues(a, b, c, d, f, g, h)
7 arguments
 
i attached my files and hoping for a response.

I took a quick look at your code, and partially debugged it. Not sure if this gets the desired results, but the main problem with your code is the variables that you are passing into the methods. I think there is also a bug in the results method, don't really have time to go through all the code, hope this helps though.

spend some time debugging your code and you should be fine. Especially check the methods and the variables your passing into them


Here is your code:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a, b, c, d, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String
        Dim duration As String
        Dim orgvisit, locate As String
        Dim expformealsandent, airlinefare, expforlodging, taxifare As Double
        Dim totals1, totals2 As Double
        InputValues(orgvisit, duration, locate, expformealsandent, airlinefare, expforlodging, taxifare)
        CalculateNumbers(expforlodging, taxifare, totals1, totals2)
        Results(orgvisit, duration, locate, expformealsandent, f, g, h, i)

        duration = TextBox2.Text

    End Sub




After a quick edit:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Dim a, b, c, d, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z As String

        Dim duration As String
        Dim orgvisit, locate As String
        Dim expformealsandent, airlinefare, expforlodging, taxifare As Double
        Dim totals1, totals2 As Double

        InputValues(orgvisit, duration, locate, expformealsandent, airlinefare, expforlodging, taxifare)
        CalculateNumbers(airlinefare, expforlodging, taxifare, totals1, totals2) 'also changed this' added a missing variable, im assuming

        Results(orgvisit, duration, expformealsandent, airlinefare, expforlodging, taxifare, totals1, totals2) 'modified this. Check the variables that you are passing in

        duration = TextBox2.Text

    End Sub
 
Back
Top