Results 1 to 9 of 9

Thread: formatting numbers in textbox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2003
    Posts
    110

    Question formatting numbers in textbox

    i am using a normal textbox.

    i want that it should remain in this format "0.00" all the time.

    when the form opens, when the data loads in it, when the user leaves the textbox, etc.
    Last edited by anis_b; Mar 24th, 2003 at 07:28 AM.
    Anis Bombaywala

  2. #2
    Fanatic Member
    Join Date
    Dec 2002
    Location
    London
    Posts
    678

    textbox

    I am new to vb.net but you may want to check out the placing the format in form_load event and the textbox_leave event or something similar?

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: textbox

    put this in the load_form event of your form !
    VB Code:
    1. TextBox1.Text = "0.00"

  4. #4
    Lively Member
    Join Date
    Jan 2003
    Posts
    69
    Use the mamask.ocx from system32 folder it looks like a text box
    and you can format how you whant in the help in vb.net there is good info,

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by cgj
    Use the mamask.ocx from system32 folder it looks like a text box
    and you can format how you whant in the help in vb.net there is good info,
    huh ?

  6. #6
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Don't use an OCX, that is a COM control. You want to avoid using them in .Net as much as possible.

    You can use something like this. The first value is the text you want formatted.

    text1.text = format("21.22","Currency")

    or check this link for a control you can easily use:
    http://www.c-sharpcorner.com/winform...dTextBoxJP.asp

  7. #7
    Lively Member
    Join Date
    Jan 2003
    Posts
    69
    hi hellswraith

    Well i didn't program before .net,
    What is wrong with com in .net?

  8. #8
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    You can do it, but .Net will create a COM wrapper class around it, and make calls to it, which in turn makes calls to the COM object. This would be slower than using something native to the .Net framework.

    Sometimes you can't get around it....and that is alright. Just try not to use COM if you can help it. The general rule is to make sure there is no .Net way of doing it before using COM.

    Also, I have found some problems with COM classes myself. Sometimes methods don't work as they should. That just is my experience.

    Hope that helps.

  9. #9
    Lively Member
    Join Date
    Jan 2003
    Posts
    69
    Good to know thank you

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