Click here to Skip to main content
14,700,041 members
Home » Discussions » Visual Basic
   

Visual Basic

 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 1:33
mveRichard MacCutchan22-Mar-20 1:33 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 2:04
MemberMember 1356965022-Mar-20 2:04 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 5:03
mveRichard MacCutchan22-Mar-20 5:03 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 5:18
MemberMember 1356965022-Mar-20 5:18 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 5:47
mveRichard MacCutchan22-Mar-20 5:47 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 6:01
MemberMember 1356965022-Mar-20 6:01 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 6:12
mveRichard MacCutchan22-Mar-20 6:12 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 6:11
mveRichard MacCutchan22-Mar-20 6:11 
OK, I have got it working (I think). You need the following changes to your code:
' Add the following at the beginning of your class
Dim handler As EventHandler  '  create an event handler type

Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

    ' InputRTB is a richtextbox in myForm

    handler = AddressOf NewInputTextChanged ' set the address of the handler
    AddHandler InputRTB.TextChanged, handler ' use the variable, NOT AddressOf
End Sub

' slTextBox is a textbox in myForm

Private Sub NewInputTextChanged()        ' my event handler
    slTextBox.Text = InputRTB.Text.Length.ToString
End Sub

' DoButton is a Button in myForm
Private Sub DoButton_Click(sender As Object, e As EventArgs) Handles DoButton.Click
    ' use handler NOT AddressOf
    RemoveHandler InputRTB.TextChanged, handler ' disable eventhandler
    DoProcess()
    AddHandler InputRTB.TextChanged, handler ' enable eventhandler

End Sub

GeneralRe: event handler Pin
Member 1356965022-Mar-20 6:48
MemberMember 1356965022-Mar-20 6:48 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 6:52
mveRichard MacCutchan22-Mar-20 6:52 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 6:52
MemberMember 1356965022-Mar-20 6:52 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 6:53
mveRichard MacCutchan22-Mar-20 6:53 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 7:13
MemberMember 1356965022-Mar-20 7:13 
GeneralRe: event handler Pin
Victor Nijegorodov22-Mar-20 1:48
MemberVictor Nijegorodov22-Mar-20 1:48 
QuestionIssue Adding a WebService (WSDL) Pin
Member 1185690418-Mar-20 14:06
MemberMember 1185690418-Mar-20 14:06 
Questionvb.net Pin
ago248616-Mar-20 2:23
Memberago248616-Mar-20 2:23 
SuggestionRe: vb.net Pin
Richard Deeming16-Mar-20 10:41
mveRichard Deeming16-Mar-20 10:41 
QuestionDeveloping a Restaurant Billing System Pin
Meax10-Mar-20 2:36
MemberMeax10-Mar-20 2:36 
AnswerRe: Developing a Restaurant Billing System Pin
Eddy Vluggen10-Mar-20 3:05
professionalEddy Vluggen10-Mar-20 3:05 
GeneralRe: Developing a Restaurant Billing System Pin
Meax12-Mar-20 1:43
MemberMeax12-Mar-20 1:43 
GeneralRe: Developing a Restaurant Billing System Pin
Richard Deeming12-Mar-20 2:18
mveRichard Deeming12-Mar-20 2:18 
GeneralRe: Developing a Restaurant Billing System Pin
Eddy Vluggen12-Mar-20 2:41
professionalEddy Vluggen12-Mar-20 2:41 
AnswerRe: Developing a Restaurant Billing System Pin
David Mujica11-Mar-20 11:53
MemberDavid Mujica11-Mar-20 11:53 
GeneralRe: Developing a Restaurant Billing System Pin
Meax12-Mar-20 1:43
MemberMeax12-Mar-20 1:43 
GeneralRe: Developing a Restaurant Billing System Pin
Gerry Schmitz15-Mar-20 8:21
mveGerry Schmitz15-Mar-20 8:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.