Visual Basic Sequential Access File- Displaying dollar sign with two decimal places

Who knows how to format the numbers entered into the txtGrossPay.txt to have a dollar sign ($) with two decimal places, that also displays in the list box?

Option Explicit On
Option Strict On
Option Infer Off

Public Class frmMain

    Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
    End Sub

    Private Sub txtGrossPay_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtGrossPay.KeyPress
        ' allows the text box to accept only numbers, the period, and the Backspace key

        If (e.KeyChar < "0" OrElse e.KeyChar > "9") AndAlso e.KeyChar <> "." _
            AndAlso e.KeyChar <> ControlChars.Back Then
            e.Handled = True
        End If
    End Sub

    Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        ' saves a gross pay amount to a sequential access file

        ' declare a StreamWriter variable
        Dim outfile As IO.StreamWriter

        'open the file for append
        outfile = IO.File.AppendText("gross.txt")

        ' write the name on a seperate line in the file

        ' close the file

        ' clear the list box, then set focus
    End Sub

    Private Sub btnDisplay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
        ' reads gross pay amount from a sequential access file
        ' and displays them in the list

        ' declare variables
        Dim inFile As IO.StreamReader
        Dim strGrossPay As String

        'determine whether file exists
        If IO.File.Exists("gross.txt") Then

            ' open file for input
            inFile = IO.File.OpenText("gross.txt")

            'process loop instructions until end of file
            Do Until inFile.Peek = -1
                strGrossPay = inFile.ReadLine

                'add gross pay amount to list box


            'close the file
            MessageBox.Show("Can't seem to find her for you sir!")
        End If
    End Sub
End Class

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.