Validating textbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rajesh

    #1

    Validating textbox

    I had created one application in .net.Now want to check whether any
    user enters correct string or not.If any user entering an incorrect
    string display an error msg.How can i do this validation.In numeich it
    works fine.But in String it's not working .

  • Anand[MVP]

    #2
    RE: Validating textbox

    How are you trying to validate? Are you writing code? Are you using a
    Validation Control?

    What is the error you are getting?

    --
    Rgds,
    Anand
    VB.NET MVP



    "Rajesh" wrote:
    [color=blue]
    > I had created one application in .net.Now want to check whether any
    > user enters correct string or not.If any user entering an incorrect
    > string display an error msg.How can i do this validation.In numeich it
    > works fine.But in String it's not working .
    >
    >[/color]

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Validating textbox

      "Rajesh" <79rajesh@gmail .com> schrieb:[color=blue]
      >I had created one application in .net.Now want to check whether any
      > user enters correct string or not.If any user entering an incorrect
      > string display an error msg.How can i do this validation.In numeich it
      > works fine.But in String it's not working .[/color]

      Place an ErrorProvider component on the form and add this code:

      \\\
      Imports System.Componen tModel
      ..
      ..
      ..
      Private Sub TextBox1_Valida ting( _
      ByVal sender As Object, _
      ByVal e As CancelEventArgs _
      ) Handles TextBox1.Valida ting
      Dim SourceControl As TextBox = DirectCast(send er, TextBox)
      Dim ErrorText As String
      Try
      Dim i As Integer = Integer.Parse(S ourceControl.Te xt)
      Catch
      ErrorText = "Value must be an integer."
      Finally
      Me.ErrorProvide r1.SetError( _
      SourceControl, _
      ErrorText _
      )
      End Try
      End Sub
      ///

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      Working...