none
Converting number in textbox to currency after calculation RRS feed

  • Question

  • Hi All

    I am designing a user form whereby it would calculate the total cost after performing rate * quantity

    However I have encounter difficulties whereby the vba is able to calculate the total cost but could not convert to currency.

    Are there anyone who could advise me on where the code has gone worng?

    Below is the code

    Private Sub TxtAmount_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y As Single)


    Me.TxtAmount.Value = Me.TxtBoxQuantity * Me.TxtBoxRate
    Me.TxtAmount.Value = Format(Me.TxtAmount.Value, "Currency")


    End Sub
    Wednesday, November 22, 2017 4:55 AM

All replies

  • Hi,

    I don't know your currency. If it is "$", you can code like this.
    Me.TxtAmount.Value = Format(Me.TxtAmount.Value, "$ 0.00")
    Regards,

    Ashidacchi


    P.S. 
    I'm sorry, your code works fine in my Excel (UserForm).
    Please provide the error message, or insert a screenshot of the shown text in TxtAmount.

    • Edited by Ashidacchi Wednesday, November 22, 2017 6:27 AM
    Wednesday, November 22, 2017 6:21 AM