I've been learning visual basic lately and decided to do a some code using functions,file reading and writelines. the way I'm trying to make it work, the code should be getting information from files I've written and should produce a file after the program itself runs, as well as a messagebox popping up to say that the program is finished. However, I currently can't even get the messagebox to pop up. I'm not sure what I've done wrong, and although I know this specific project is an odd one I've included the code for it below in the hopes someone can help me with it as I can't find any examples that are exactly similar to what I'm attempting. Anyways, any help would be appreciated, thank you!
Imports System.IO
Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Dim fs As New System.IO.FileStream("a9output.txt", IO.FileMode.Create, IO.FileAccess.Write)
Dim w As New StreamWriter(fs)
Dim sr As IO.StreamReader = IO.File.OpenText("a8.txt")
While sr.Peek <> -1
Dim Strinput As String
Strinput = sr.ReadLine
Dim input = Strinput.Split(",")
Dim age As Double = Val(input(3))
Dim SD = CalcSD(age)
Dim Tax = CalcTaxable(SD, age, Strinput)
w.WriteLine("Name: " & input(0))
w.WriteLine("Taxable Income:" & Tax)
w.WriteLine("Age:" & input(3))
w.WriteLine("Program Completed")
MsgBox("Program Completed!")
End While
sr.Close()
w.Close()
End Sub
Function CalcSD(ByVal age As Integer) As Double
Dim SD As Double
If age >= 65 Then
SD = 17500
Else
SD = 12500
End If
Return SD
End Function
Function CalcTaxable(ByVal SD As Double, age As Double, strinput As String) As Double
Dim sr As IO.StreamReader = IO.File.OpenText("a8.txt")
Dim sum As Double
strinput = sr.ReadLine
Dim Input() = strinput.Split(",")
Dim name As Double = Val(Input(0))
Dim income As Double = Val(Input(1))
Dim contribution As Double = Val(Input(2))
sum = income - contribution - SD
Return sum
End Function
End Class