Click here to Skip to main content
15,881,938 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 0:33
mveRichard MacCutchan22-Mar-20 0:33 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 1:04
Member 1356965022-Mar-20 1:04 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 4:03
mveRichard MacCutchan22-Mar-20 4:03 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 4:18
Member 1356965022-Mar-20 4:18 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 4:47
mveRichard MacCutchan22-Mar-20 4:47 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 5:01
Member 1356965022-Mar-20 5:01 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 5:12
mveRichard MacCutchan22-Mar-20 5:12 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 5:11
mveRichard MacCutchan22-Mar-20 5:11 
OK, I have got it working (I think). You need the following changes to your code:
VB
' 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 5:48
Member 1356965022-Mar-20 5:48 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 5:52
mveRichard MacCutchan22-Mar-20 5:52 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 5:52
Member 1356965022-Mar-20 5:52 
GeneralRe: event handler Pin
Richard MacCutchan22-Mar-20 5:53
mveRichard MacCutchan22-Mar-20 5:53 
GeneralRe: event handler Pin
Member 1356965022-Mar-20 6:13
Member 1356965022-Mar-20 6:13 
GeneralRe: event handler Pin
Victor Nijegorodov22-Mar-20 0:48
Victor Nijegorodov22-Mar-20 0:48 
QuestionIssue Adding a WebService (WSDL) Pin
Member 1185690418-Mar-20 13:06
Member 1185690418-Mar-20 13:06 
Questionvb.net Pin
ago248616-Mar-20 1:23
ago248616-Mar-20 1:23 
SuggestionRe: vb.net Pin
Richard Deeming16-Mar-20 9:41
mveRichard Deeming16-Mar-20 9:41 
QuestionDeveloping a Restaurant Billing System Pin
Meax10-Mar-20 1:36
Meax10-Mar-20 1:36 
AnswerRe: Developing a Restaurant Billing System Pin
Eddy Vluggen10-Mar-20 2:05
professionalEddy Vluggen10-Mar-20 2:05 
GeneralRe: Developing a Restaurant Billing System Pin
Meax12-Mar-20 0:43
Meax12-Mar-20 0:43 
GeneralRe: Developing a Restaurant Billing System Pin
Richard Deeming12-Mar-20 1:18
mveRichard Deeming12-Mar-20 1:18 
GeneralRe: Developing a Restaurant Billing System Pin
Eddy Vluggen12-Mar-20 1:41
professionalEddy Vluggen12-Mar-20 1:41 
AnswerRe: Developing a Restaurant Billing System Pin
David Mujica11-Mar-20 10:53
David Mujica11-Mar-20 10:53 
GeneralRe: Developing a Restaurant Billing System Pin
Meax12-Mar-20 0:43
Meax12-Mar-20 0:43 
GeneralRe: Developing a Restaurant Billing System Pin
Gerry Schmitz15-Mar-20 7:21
mveGerry Schmitz15-Mar-20 7: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.