Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. HOW CAN I PREVENT STRING VALUE IN TEXTBOX

HOW CAN I PREVENT STRING VALUE IN TEXTBOX

Scheduled Pinned Locked Moved Visual Basic
helpquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vivek_pon
    wrote on last edited by
    #1

    Private Sub txt_ord_qty_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_ord_qty.KeyPress If IsNumeric((e.KeyChar)) = False Then MsgBox("ENTER ONLY NUMERIC VALUE") End If End Sub I M USING THIS CODE BUT AFTER MESSAGE IT INSERT VALUE IN TEXTBOX HOW CAN I PREVENT STRING VALUE IN TEXTBOX PLEASE HELP ME asdf

    B O A V 4 Replies Last reply
    0
    • V vivek_pon

      Private Sub txt_ord_qty_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_ord_qty.KeyPress If IsNumeric((e.KeyChar)) = False Then MsgBox("ENTER ONLY NUMERIC VALUE") End If End Sub I M USING THIS CODE BUT AFTER MESSAGE IT INSERT VALUE IN TEXTBOX HOW CAN I PREVENT STRING VALUE IN TEXTBOX PLEASE HELP ME asdf

      B Offline
      B Offline
      Briga
      wrote on last edited by
      #2

      Have you check if there's a cancel property available under e? Otherwise strip last char in the text property.

      1 Reply Last reply
      0
      • V vivek_pon

        Private Sub txt_ord_qty_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_ord_qty.KeyPress If IsNumeric((e.KeyChar)) = False Then MsgBox("ENTER ONLY NUMERIC VALUE") End If End Sub I M USING THIS CODE BUT AFTER MESSAGE IT INSERT VALUE IN TEXTBOX HOW CAN I PREVENT STRING VALUE IN TEXTBOX PLEASE HELP ME asdf

        O Offline
        O Offline
        Owner drawn
        wrote on last edited by
        #3

        You can set e.Handled to true.

        Jesus Loves:rose:

        --Owner Drawn:rose: --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord:rose:

        1 Reply Last reply
        0
        • V vivek_pon

          Private Sub txt_ord_qty_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_ord_qty.KeyPress If IsNumeric((e.KeyChar)) = False Then MsgBox("ENTER ONLY NUMERIC VALUE") End If End Sub I M USING THIS CODE BUT AFTER MESSAGE IT INSERT VALUE IN TEXTBOX HOW CAN I PREVENT STRING VALUE IN TEXTBOX PLEASE HELP ME asdf

          A Offline
          A Offline
          abhinish
          wrote on last edited by
          #4

          did u tried return after the msgbox in the if condition abhinav

          1 Reply Last reply
          0
          • V vivek_pon

            Private Sub txt_ord_qty_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txt_ord_qty.KeyPress If IsNumeric((e.KeyChar)) = False Then MsgBox("ENTER ONLY NUMERIC VALUE") End If End Sub I M USING THIS CODE BUT AFTER MESSAGE IT INSERT VALUE IN TEXTBOX HOW CAN I PREVENT STRING VALUE IN TEXTBOX PLEASE HELP ME asdf

            V Offline
            V Offline
            vinji
            wrote on last edited by
            #5

            hi vivek the code that i m giving u will definately help u in the key press event of the textbox write the following code if char.isNumber(e.keyChar) = false then e.handled=true end if karan jain(Vinit Jain)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups