Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If e.KeyChar < "0" Or e.KeyChar > "9" Then

If e.KeyChar = Chr(8) Or e.KeyChar = "." Then

Exit Sub

End If

e.Handled = True

^^^^^^^^^^^

End If

End Sub

 

 

I have a problem with the concept of e.handled...

on my own, if e.handled=true that is mean that it should

handle wat i type and show it on the textbox....

if e.handled=false it means that It should not handle wat I type

and dun show it on the textbox....However wat I think is wrong

and or all inverse....Can experts explain to me? Really Thanks:)

  • Leaders
Posted (edited)

i dont know if you've used vb6, but if you imagine the unload event, if you set Cancel to 1, you can't unload ( which would be an equivalent to a boolean of True )

'/// This is VB6 Code...
Private Sub Form_Unload(Cancel As Integer)
If Cancel = False Then
   '/// basically same as e.Handled = False
   MsgBox "it's ok to unload! the cancel value is 0"
ElseIf Cancel = True Then
   '/// e.Handled = True
   MsgBox "you can't unload, the value is 1"
End If
End Sub

not sure if that explains it for you or not.

Edited by dynamic_sysop

  • Administrators
Posted

e.Handled = true means you have dealt with the keypress and no further action is required by the control, normally this will result in the key that had been pressed being ignored by the control.

 

e.Handled = false means the control can carry on and process the keystroke.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...