Results 1 to 6 of 6

Thread: How do I get this TextBox13 code to display in Currency Format

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    376

    How do I get this TextBox13 code to display in Currency Format

    Code:
    'TextBox13
    
            '
    
            Me.TextBox13.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    
            Me.TextBox13.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.objMachinesAndReadings, _ "Readings.Sel_1_Paid"))
    
            Me.TextBox13.Location = New System.Drawing.Point(79, 56)
    
            Me.TextBox13.Name = "TextBox13"
    
            Me.TextBox13.ReadOnly = True
    
            Me.TextBox13.Size = New System.Drawing.Size(56, 20)
    
            Me.TextBox13.TabIndex = 1
    
            Me.TextBox13.TabStop = False
    
            Me.TextBox13.Text = ""
    
            Me.TextBox13.TextAlign = System.Windows.Forms.HorizontalAlignment.Center

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    VB Code:
    1. Dim curr As Single = 12.74
    2.         TextBox1.Text = curr.ToString("C")

    This will display the currency value in the correct format for the locale that your PC is set up for.

    Go into Regional Options in the control panel and select a different locale before running the code and see the difference.
    This world is not my home. I'm just passing through.

  3. #3
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Having said that, my system seems not to have caught up with the fact that Europe is now using Euros...

    Anybody know if there's an update out for that yet?
    This world is not my home. I'm just passing through.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    376
    trisuglow:

    Do you meant this?

    Code:
       'TextBox13
            '
            Dim curr As Single = 12.74
            Me.TextBox13.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
            Me.TextBox13.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.objMachinesAndReadings, "Readings.Sel_1_Paid"))
            Me.TextBox13.Location = New System.Drawing.Point(79, 56)
            Me.TextBox13.Name = "TextBox13"
            Me.TextBox13.ReadOnly = True
            Me.TextBox13.Size = New System.Drawing.Size(56, 20)
            Me.TextBox13.TabIndex = 1
            Me.TextBox13.TabStop = False
            Me.TextBox13.Text = ""
            Me.TextBox13.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
            Me.TextBox13.Text = curr.ToString("c")

  5. #5
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    No.

    I mean, when you put text into the box do it like I said.

    I don't think you can configure the properties of the textbox to automatically format the text unless you put it into a user control or subclass it.

    I'm going home for the weekend now, but if you want more info I'll probably have a chance to look at VBForums on Tuesday.


    Tris.
    This world is not my home. I'm just passing through.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2003
    Posts
    376
    trisuglow

    Thank you very much

    this worked just fine;
    Code:
       TextBox74.Text = CDec(TextBox74.Text).ToString("c")
    Andy

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