Results 1 to 7 of 7

Thread: [2005] how to format as integer

Hybrid View

  1. #1
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,422

    Re: [2005] how to format as integer

    check it first with integer.tryparse

    vb Code:
    1. if integer.tryparse(ctype(math.round(ctype(TextBox1.Text, decimal)), integer), number) then
    2.    number = ctype(math.round(ctype(TextBox1.Text, decimal)), integer)
    3. end if

  2. #2
    Frenzied Member Icyculyr's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    1,934

    Re: [2005] how to format as integer

    1.00 is a decimal, not an integer..

    Code:
    Dim myDecimal As Decimal = 1.57
    If Decimal.TryParse(TextBox1.Text, myDecimal) Then
        myDecimal = Math.Round(myDecimal)
        MsgBox("Success")
    Else
        MsgBox("Failure")
    End If

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