Results 1 to 6 of 6

Thread: Type of currency

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    45

    Type of currency

    Hi all

    I have a small program.

    For example: When I input data at textbox1.text="123456"
    then textbox2.text will appear ="123.456"

    How to solve.
    Help me.

  2. #2
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Type of currency

    One of several ways:
    Code:
    Private Sub Text1_KeyPress(KeyAscii As Integer)
    Static intCount As Integer
    Text2.Text = Text2.Text & Chr(KeyAscii)
    intCount = intCount + 1
    If intCount = 3 Then Text2.Text = Text2.Text & "."
    End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    45

    Re: Type of currency

    Thanks Doogle.
    I mean that. If I have textbox1=12345678 then textbox2=12.345.678
    It is the same Type of currency

    Pleasev help me

  4. #4
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: Type of currency

    I assume that '.' is your currency separator.

    The easiest method might be to put some code in the LostFocus event of Text1
    Code:
    Private Sub Text1_LostFocus()
    Text2.Text = Format(Text1.Text, "##.###.###")
    End Sub
    when you move the cursor out of Text1, Text2 should contain the formatted data

  5. #5
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Type of currency

    You must use "," as thousand separator in Format() even your local thousand separator is "."
    Code:
    Text2.Text = Format(Text1.Text, "#,##0")
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  6. #6

    Thread Starter
    Member
    Join Date
    Jan 2011
    Posts
    45

    Re: Type of currency

    Thank anhn very much

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