TextBox.Text Average?

Discussion in 'Questions (Windows Mobile)' started by cdeane, Apr 24, 2008.

  1. cdeane

    cdeane Member

    How do I get a average of .125 or less In a TextBox?
    And can I center the text in a TextBox?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What do you mean with getting an average?

    You can change the text alignment with FormLib.TextAlignment.
     
  3. cdeane

    cdeane Member

    Thanks for the text alignment help Erel.

    By average I mean that I get something like 50.1246887 in my TextBox but I need
    50.125.
    If I resize the TextBox to fit then I may need a diffrent value at some point like 23.5 in which case the TextBox would then read 23.495 which I do not need.
     
  4. BerndB

    BerndB Member Licensed User

    Hi cdeane,

    What you need, I think, is
    round(yourValue,3)
    for 3 digits.

    val = 56.123432
    textbox.text = round(val,3)
    delivers 56.123

    I hope I'm right and this helps

    regards
    Bernd
     
  5. specci48

    specci48 Well-Known Member Licensed User

    Or you can use the format function:

    Code:
    Msgbox (Format(1234.5678,"N2"))
    Will display: 1,234.57


    specci48
     
  6. cdeane

    cdeane Member

    I do not know what value the TextBox will throug out at any given time.

    I need someting like : Round(TextBox.Text,2)
    Which of course dose not seem to work.
     
  7. klaus

    klaus Expert Licensed User

    It depends on what you want to do.

    - do you want do display a variable like x=54.124678 but roundet with 3 digits after the decimal point ?
    This is the case of both suggested solutions.
    Ex. TextBox1.Text=Round(x,3)

    - do you want to allocate the value in the TextBox to a variable but rounded ?
    Ex. x=Round(TextBox1.Text,3)

    - do you want the variable in the Textbox rounded during input ?
    This would be somewhat more complicated, but you can use the Door library
    and look at agrahams example of Uppercase in textbox or the livefilter example and adpt it to your requirement.
    You will find this in:
    http://www.basic4ppc.com/forum/showthread.php?t=2183

    Best regards
     
  8. cdeane

    cdeane Member

    YES!
    Your exatcly right Klaus.
    I want it done at input. ei, TextBox1.Text=TextBox2.Text+TextBox3 ,then have it rounded out.

    Ill see what the link will produce.
     
  9. klaus

    klaus Expert Licensed User

    Is it this what you are looking for ?

    Best regards
     

    Attached Files:

  10. cdeane

    cdeane Member

    Thanks Klaus,
    That looks like what Im looking for.
    Much apreciation to every ones advice.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice