Results 1 to 2 of 2

Thread: Problem with converting decimals in textboxes to strings

  1. #1
    Guest

    Post

    I have a function in my program that reads a string from a textbox and makes sure it only contains numbers with 2 decimal places. This works fine, until you put in a number into the textbox where the decimal places are zero's. ie VB converts "10.00" to "10". How can I get the string to include the zero's ?? Any suggestions.

  2. #2
    Fanatic Member r0ach's Avatar
    Join Date
    Dec 1999
    Location
    South Africa
    Posts
    722

    Post

    Why not try:
    Code:
        Dim MyValue as Single
        MyValue = CSng(Text1.Text)
    This should work!

    Oh yes. And remember to format. Without formatting, 10.00 would come out as 10.
    Code:
        ' To go with top code
        MyValue = Format(MyValue, "###,##0.00")
    Hope this helps.

    Edited by r0ach on 02-24-2000 at 07:46 AM

    r0ach™
    Don't forget to rate the post

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