View Single Post
  #6 (permalink)  
Old June 8th, 2006, 11:53 PM
Shyam Bharath Shyam Bharath is offline
Authorized User
 
Join Date: Jun 2006
Location: Hyderabad, AP, India.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi...

The previous code was for WindowsApplication

This one is for Web Application

Anyway, let us assume that u are taking input in a textbox in a web app. First set AutoPostBack to True

Then wirte the following code in the event OnTextChanged

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Dim str As String
        str = TextBox1.Text
        If Not IsNumeric(str) Then
            Response.Write("Enter a Number !!! ")
            TextBox1.Focus()
        End If
End Sub

On Losing focus OR On submitting, it will check it a number is entered. Or alternately as Benson suggested, use a CompareValidator
Regards