Change Text Box to minus figure

I have a form where the user chooses descriptions from a Combo box and then enters a cost value in a text box.
If the users enters predefined description such as "Discount" into the combo box I would like to automatically change the text box so that whatever amount is entered shows as a minus figure.
Any help gratefully received.
iainmacleodAsked:
Who is Participating?
 
Rgonzo1971Commented:
Hi,

pls try

Private Sub Text0_Exit(Cancel As Integer)
    If Combo1.Value = "Discount" Then
        Text0.Value = -Abs(Text0.Value)
    Else
        'Nothing changes
    End If
End Sub

Open in new window

Regards
0
 
Gustav BrockCIOCommented:
I assume you do not want to modify the actual value of the number in the textbox.

You could do some fancy modification of the Format property of the textbox.

The easiest method, however, is to position a small label in front of the textbox. Then, if "Discount" is chosen, set the caption of the label to "-". Set the caption to "" (empty string) for normal cases.

/gustav
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.