Avoiding Keyboard Errors

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

    Avoiding Keyboard Errors

    Is there somthing I can use for a text box control that will help
    avoid my users of entering "stupid" data. In many cases our user will
    enter number such as 10.0 or 0.50 or even 0,45 however if my user
    enter ..045 or ,,045 how can i control this and prompt him to re-
    enter. I thought of using the replace function however I don;t know
    what direction to take with this. Could someone please point me on the
    right track???
  • kimiraikkonen

    #2
    Re: Avoiding Keyboard Errors

    On Feb 27, 6:27 pm, cmdolcet69 <colin_dolce... @hotmail.comwro te:
    Is there somthing I can use for a text box control that will help
    avoid my users of entering "stupid" data. In many cases our user will
    enter number such as 10.0 or 0.50 or even 0,45 however if my user
    enter ..045 or ,,045 how can i control this and prompt him to re-
    enter. I thought of using the replace function however I don;t know
    what direction to take with this. Could someone please point me on the
    right track???
    Hi,
    Replace function can be used, in this sample you may correct incorrect
    user entries that are done with " . " instead of
    " , ":

    If TextBox1.Text.C ontains(".") = True Then
    TextBox1.Text = TextBox1.Text.R eplace(".", ",")
    End If
    End Sub




    Comment

    • rowe_newsgroups

      #3
      Re: Avoiding Keyboard Errors

      On Feb 27, 11:27 am, cmdolcet69 <colin_dolce... @hotmail.comwro te:
      Is there somthing I can use for a text box control that will help
      avoid my users of entering "stupid" data. In many cases our user will
      enter number such as 10.0 or 0.50 or even 0,45 however if my user
      enter ..045 or ,,045 how can i control this and prompt him to re-
      enter. I thought of using the replace function however I don;t know
      what direction to take with this. Could someone please point me on the
      right track???
      I also should have mentioned you can use the MaskedEditTextB ox to
      restrict what data can be entered.

      Thanks,

      Seth Rowe [MVP]

      Comment

      • Cor Ligthert[MVP]

        #4
        Re: Avoiding Keyboard Errors

        Hi,

        Beside the maskededit box is of course the good old but also in .Net
        function IsNumeric good enough.

        In fact it is an optimized and simple to use TryParse but in my idea more
        then good enough for your purpose.



        Cor

        "cmdolcet69 " <colin_dolcetti @hotmail.comsch reef in bericht
        news:1a4d86c0-87e5-4228-8d65-f395d7a2c359@n5 8g2000hsf.googl egroups.com...
        Is there somthing I can use for a text box control that will help
        avoid my users of entering "stupid" data. In many cases our user will
        enter number such as 10.0 or 0.50 or even 0,45 however if my user
        enter ..045 or ,,045 how can i control this and prompt him to re-
        enter. I thought of using the replace function however I don;t know
        what direction to take with this. Could someone please point me on the
        right track???

        Comment

        • Herfried K. Wagner [MVP]

          #5
          Re: Avoiding Keyboard Errors

          "cmdolcet69 " <colin_dolcetti @hotmail.comsch rieb:
          Is there somthing I can use for a text box control that will help
          avoid my users of entering "stupid" data. In many cases our user will
          enter number such as 10.0 or 0.50 or even 0,45 however if my user
          enter ..045 or ,,045 how can i control this and prompt him to re-
          enter.
          \\\
          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 n As Double
          If Not Double.TryParse (SourceControl. Text, n) Then
          Me.ErrorProvide r1.SetError( _
          SourceControl, _
          "Value must be a double." _
          )
          Else
          If Me.ErrorProvide r1.GetError(Sou rceControl).Len gth 0 Then
          Me.ErrorProvide r1.SetError(Sou rceControl, String.Empty)
          End If
          ...
          End If
          End Sub
          ///

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

          Comment

          Working...