ToString("C") does not show expected result in VB

198 Views Asked by At

The input changes to $0.00 whenever i try this coding:

Private Sub btnEnt_Click(sender As Object, e As EventArgs) Handles btnEnt.Click

    Dim result As String

    Dim earn As Decimal

    txtEarning.Text = earn.ToString("C")

    result = txtFName.Text & " " & txtLName.Text & " Worked" & vbCrLf

    result &= nudHr.Value & " Hrs today"

    result &= " and his earning is " & txtEarning.Text

    txtRes.Text = result

End Sub

enter image description here

instead of displaying input value, the value automatically converts to $0.00

1

There are 1 best solutions below

0
Caius Jard On

I think you might need this:

Dim earn as Decimal = nudHr.Value * 20

If your person earns 20 dollars an hour