# How Do I make a Positive Number Into A Negative Number

471 Reputation points
2023-06-17T15:49:09.1333333+00:00

Hi Good People

On My Form I have Three Textboxes ( TxtTotalEarned, TxtVHMoneyTotalDed, TxtSubTotal, )

When The Form Loads And I Select A Name from a Drop Down Box Then my Textbox TxtTotalEarned, is loaded with currency data. Also The Textbox TxtVHMoneyTotalDed is also Loaded with Currency Data.

It is here where I want to change the Data in the TxtVHMoneyTotalDed to a negative Currency Data.

At the Moment My Data Shows £40.00. where I want it to show -£40.00.

then show the result in the textbox ,TxtSubTotal.

Is there a way this can be done. I have done some research and tried different code, (WinForms VB)

Kind Regards

Gary

``````    If GetDec(TxtVHMoneyTotal.Text) > "0.00" Then
TxtVHMoneyTotalDed.Show()
LbVHMoneyTotalCaption.Show()
TxtSubTotal.Show()
LbSubTotal.Show()

Dim Sum1 As Decimal = GetDec(TxtTotalEarned.Text)
Dim Sum2 As Decimal = GetDec(TxtVHMoneyTotal.Text) * -1

TxtSubTotal.Text = FormatCurrency(Sum1 - Sum2)

End If

End Sub
``````
VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,694 questions

1. 30,201 Reputation points Microsoft Vendor
2023-06-21T07:49:30.7566667+00:00

Please check if the following code helps.

``````        Dim value As Decimal
Decimal.TryParse(TxtVHMoneyTotal.Text.Replace("£", ""), value)
TxtVHMoneyTotalDed.Text = String.Format("-£{0:N2}", Math.Abs(value))
``````

Best Regards.

Jiachen Li