Click here to Skip to main content
15,904,155 members
Home / Discussions / C#
   

C#

 
QuestionHow can I replace all text in a listBox1 that matches "some text " with "other text "? Pin
Member 1041097226-Dec-15 8:41
Member 1041097226-Dec-15 8:41 
AnswerRe: How can I replace all text in a listBox1 that matches "some text " with "other text "? Pin
BillWoodruff26-Dec-15 9:46
professionalBillWoodruff26-Dec-15 9:46 
QuestionDynamic Treeview using C# Pin
Member 1124005623-Dec-15 19:49
Member 1124005623-Dec-15 19:49 
SuggestionRe: Dynamic Treeview using C# Pin
CHill6023-Dec-15 23:14
mveCHill6023-Dec-15 23:14 
SuggestionRe: Dynamic Treeview using C# Pin
Richard Deeming4-Jan-16 3:26
mveRichard Deeming4-Jan-16 3:26 
QuestionCountdown timer Pin
Enzotech223-Dec-15 11:05
Enzotech223-Dec-15 11:05 
AnswerRe: Countdown timer Pin
Richard MacCutchan23-Dec-15 11:14
mveRichard MacCutchan23-Dec-15 11:14 
QuestionHow do I read data from USB Virtual COM in C#? Pin
naouf1023-Dec-15 3:27
naouf1023-Dec-15 3:27 
I searched for a solution on the internet but no luck.

I am using windows form with Serial Port control and richTextBox. I am trying to read the phone number from caller ID device (CTI comet caller ID) which decodes the Caller's telephone number from the telephone line and presenting it on a virtual COM5 Port of my PC because the Caller ID is a COM device.

The caller ID is connected to my PC via USB to COM Adapter because my PC doesn't have physical COM ports. Also the USB to COM Adapter driver is installed well .Note that the telephone line supports the caller ID feature.

When the phone rings the phone number should show up in richTextBox, I tried the following code but nothing happens (phone number did not appear) Am I missing something?.

My question:

How can I read data from virtual COM5 port in C#? Please help me to modify this code to make it work. Thank you



C#
public partial class Form1 : Form
    {
      public  SerialPort mySerialPort = new SerialPort("COM5");

    public Form1()
    {
        InitializeComponent();

        mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataR);
        mySerialPort.Open();
     }

    public void DataR(object sender, SerialDataReceivedEventArgs e)

    {

        if (richTextBox1.InvokeRequired)
         {
             richTextBox1.Invoke(new SerialDataReceivedEventHandler(DataR), sender, e);
         }

         else
         {

            richTextBox1.AppendText(mySerialPort.ReadExisting()); //recieve data in real time.

          }
      }


    private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {

    }
}

AnswerRe: How do I read data from USB Virtual COM in C#? Pin
OriginalGriff23-Dec-15 3:55
mveOriginalGriff23-Dec-15 3:55 
GeneralRe: How do I read data from USB Virtual COM in C#? Pin
naouf1023-Dec-15 11:41
naouf1023-Dec-15 11:41 
AnswerRe: How do I read data from USB Virtual COM in C#? Pin
Gerry Schmitz23-Dec-15 11:07
mveGerry Schmitz23-Dec-15 11:07 
GeneralRe: How do I read data from USB Virtual COM in C#? Pin
naouf1023-Dec-15 11:39
naouf1023-Dec-15 11:39 
AnswerRe: How do I read data from USB Virtual COM in C#? Pin
OriginalGriff23-Dec-15 11:57
mveOriginalGriff23-Dec-15 11:57 
GeneralRe: How do I read data from USB Virtual COM in C#? Pin
naouf1023-Dec-15 14:30
naouf1023-Dec-15 14:30 
GeneralRe: How do I read data from USB Virtual COM in C#? Pin
Gerry Schmitz23-Dec-15 12:05
mveGerry Schmitz23-Dec-15 12:05 
GeneralRe: How do I read data from USB Virtual COM in C#? Pin
naouf1023-Dec-15 14:45
naouf1023-Dec-15 14:45 
GeneralRe: How do I read data from USB Virtual COM in C#? Pin
Gerry Schmitz23-Dec-15 16:11
mveGerry Schmitz23-Dec-15 16:11 
AnswerRe: How do I read data from USB Virtual COM in C#? Pin
Luc Pattyn23-Dec-15 17:24
sitebuilderLuc Pattyn23-Dec-15 17:24 
GeneralRe: How do I read data from USB Virtual COM in C#? Pin
naouf1026-Dec-15 3:44
naouf1026-Dec-15 3:44 
GeneralRe: How do I read data from USB Virtual COM in C#? Pin
Agent__00730-Dec-15 15:45
professionalAgent__00730-Dec-15 15:45 
QuestionIs there a better way to call Same Methods on different objects ? Pin
Emanuele Bonin23-Dec-15 0:03
Emanuele Bonin23-Dec-15 0:03 
AnswerRe: Is there a better way to call Same Methods on different objects ? Pin
Richard MacCutchan23-Dec-15 0:30
mveRichard MacCutchan23-Dec-15 0:30 
AnswerRe: Is there a better way to call Same Methods on different objects ? Pin
Eddy Vluggen23-Dec-15 1:49
professionalEddy Vluggen23-Dec-15 1:49 
AnswerRe: Is there a better way to call Same Methods on different objects ? Pin
BillWoodruff23-Dec-15 5:04
professionalBillWoodruff23-Dec-15 5:04 
GeneralRe: Is there a better way to call Same Methods on different objects ? Pin
Eddy Vluggen23-Dec-15 6:34
professionalEddy Vluggen23-Dec-15 6:34 

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.