Results 1 to 4 of 4

Thread: how do you convert values into currency format

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    2

    how do you convert values into currency format

    i am using visual basic 6.0 and on one of my forms i need to do a calculation that calculates the difference between incomings and expenses-i have figured out this code and the code works fine

    Heres the problem, at the moment in the textbox the user can enter anything, i want it so that the user can just enter numbers-and the textbox format will be currency-i dont know how this works-maybe when the user enters for example 100 this will automatically convert into (when the user goes to next textbox) £100.00-if there is a code for this please post below cuz i am really stuck-
    here is the code i have at the moment

    Private Sub cmdCalculate_Click()


    txtProfit.Text = Val(txtIncomings.Text) - Val(txtOutgoings.Text)


    If Val(txtProfit.Text) > 0 Then
    txtProfit.ForeColor = vbGreen
    Else
    txtProfit.ForeColor = vbRed
    End If

    If Val(txtIncomings.Text) > Val(txtOutgoings.Text) Then
    lblResult.Caption = "You made a profit!"
    Else
    lblResult.Caption = "You made a loss!"
    End If

    End Sub

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how do you convert values into currency format

    Welcome to the forums.

    How to make a textbox accept only numbers is a question that gets asked a lot. Here is just one of many.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2008
    Posts
    2

    Re: how do you convert values into currency format

    that is useful but now i need to know how to convert values into currency format-read through my original question if necessary

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how do you convert values into currency format

    I read your original question.

    You don't "convert" it. If you want a number to be formatted to appear as though it is currency, then simply use the Format function.

    The Format function can take a number and make it appear to be anything you need it to be.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width