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
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