Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3441732
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:35:20+00:00 2026-05-18T08:35:20+00:00

When opening the port I add the handler and it works. What I need

  • 0

When opening the port I add the handler and it works.
What I need is, at some point, to change the handler to another subroutine..
What I did was:

AddHandler serport.DataReceived, AddressOf handler1

And the first handler worked as expected…
after some time in code I do:

RemoveHandler serport.DataReceived, AddressOf handler1  
AddHandler serport.DataReceived, AddressOf handler2  

But the second handler doesn’t work. it never gets called.
What can I do?

I also have coded this routine to open a port :

Public Function OpenSerial(ByRef serialport As String, ByVal receivehandler As SerialDataReceivedEventHandler) As SerialPort
    Dim ser As SerialPort
    ser = New System.IO.Ports.SerialPort(serialport, 115200, Parity.None, 8, StopBits.One)
    With ser
        .Handshake = Handshake.None
        .ReadBufferSize = 10000
        .ReadTimeout = 500
        .WriteBufferSize = 10000
        .WriteTimeout = 500
        .RtsEnable = True
        .DtrEnable = True
        AddHandler .DataReceived, receivehandler
        AddHandler .ErrorReceived, AddressOf sErrorHandler
        .Encoding = System.Text.Encoding.Default
        .Open()
        .DiscardOutBuffer()
    End With
    OpenSerial = ser
End Function

So I thought I could use it in this way:

Dim comSerial As SerialPort
comSerial = OpenSerial("COM1", AddressOf Handler1)

Anyhow, however I do it I get the same result: the first time, the first handler works, when redefined, even if the port is closed and reopened, the second handler never gets
called 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:35:21+00:00Added an answer on May 18, 2026 at 8:35 am

    This question was bogus.

    The program works fine. I was not receiving any data for another reason.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When opening a window, I register a Deleted-event-handler on my business object. It is
I'm opening a new browser window from my site for some of the members.
I want to use WCF to enable two way communication without opening a port
I'm trying to write my own nmea parser,since i only need some info from
I need to connect via TCP to a port that's behind a firewall, accessible
I am opening a socket on port 119 (using idHttpServer) and it opens ok
in Qt im opening QDialog windows each time i click some item im doing
I am opening a serial port using CreateFile() . I've got a testcase (too
In opening up the .xap file that is generated as output from a Silverlight
When opening a file from your hard drive into your browser, where is the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.