|
-
Dec 15th, 2007, 02:06 AM
#1
Thread Starter
Frenzied Member
[2005] how to format as integer
i want to format the text of the text box as integer without separator. Plz Help!
-
Dec 15th, 2007, 02:19 AM
#2
Frenzied Member
Re: [2005] how to format as integer
without separator? I don't know what you mean by that, but try this:
Code:
Dim myInteger As Integer = 0
If Integer.TryParse(TextBox1.Text, myInteger) Then
MsgBox("Success")
Else
MsgBox("Failure")
End If
-
Dec 15th, 2007, 02:30 AM
#3
Thread Starter
Frenzied Member
Re: [2005] how to format as integer
you code isn't working as i want.
if i enter 1.00 then it is returning 'failure'. i want it to be formated as '1'. and if i enter 1.56 then it must be formated as '2'.
by separator i mean the commas in the number i.e 1,234,345,678.00
-
Dec 15th, 2007, 02:46 AM
#4
Re: [2005] how to format as integer
dim number as integer = ctype(math.round(ctype(TextBox1.Text, decimal)), integer)
-
Dec 15th, 2007, 03:02 AM
#5
Thread Starter
Frenzied Member
Re: [2005] how to format as integer
Code:
dim number as integer = ctype(math.round(ctype(TextBox1.Text, decimal)), integer)
what if the user enters characters in textbox1
-
Dec 15th, 2007, 03:08 AM
#6
Re: [2005] how to format as integer
check it first with integer.tryparse
vb Code:
if integer.tryparse(ctype(math.round(ctype(TextBox1.Text, decimal)), integer), number) then
number = ctype(math.round(ctype(TextBox1.Text, decimal)), integer)
end if
-
Dec 15th, 2007, 04:21 AM
#7
Frenzied Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|