Unable to properly use VS Serial Monitor but Arduino IDE works

sumguy:
Simply put serial communication is usually communication between two devices, say device A and Device B.

Device A and B use a com port of some kind to communicate, as in your case it is com 3, usually A and B are the only devices allowed to use this com port.

Lets say device A is the arduino and device B is the PC, the sketch of the arduino has access to com 3 and so does the PC.

There is another rule we must be aware of and that is the PC is only allowed to use one application or program to access com 3 at a time. This means we can use a Visual Studio app or we can use the arduino IDE Serial Monitor app, we can NOT use both at the same time.

The solution is to build a serial monitor into your VS application. The following code is the beginning of a C# program as a simple monitor and test utility for serial comms.

Serial lines communicate using byte values, a byte can be a value from 0 to 255. When displaying text chars or strings the byte value will be in the range 32 to 127.The fact a serial byte can be a character or a numeric value is something both ends of the communication line need to be aware of. This makes more sense when you can actually see the results displayed from your serial transmissions. In this particular app Robin2 has an arduino program that echoes back the character you send, so we have a routine in VS that is purposely written to send and display a character

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
using System.Collections;

namespace WindowsFormsApplication7
{
    public partial class Form1 : Form
    {

SerialPort port = new SerialPort();
        public delegate void myDelegate(byte sData);

public Form1()
        {
            InitializeComponent();
        }

private void Form1_Load(object sender, EventArgs e)
        {
            port.PortName = "COM3";
            port.Open();
            port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
            port.ReadExisting();
        }

private void stringDebug(byte sData)
        {

string s = Convert.ToString((char)sData);
            richTextBox1.AppendText(s);

}

private void port_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)

{
            byte myData;
            port.ReadTimeout = 20;
            while (port.BytesToRead > 0)
            {
                try
                {
                    myData = System.Convert.ToByte(port.ReadByte());
                    this.BeginInvoke((new myDelegate(stringDebug)), myData);
                }

catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

}

}

private void button1_Click(object sender, EventArgs e)
        {
            port.Write("A");
        }
    }
}




The routine displaying the character is the "stringDebug" delegate, modifying this routine allows us interpret the byte values in several different ways.

If you have any questions or would like to expand the sample serial monitor 

I forgot to mention that the C# app has only two controls.....a richTextbox and a Button

Thanks for all this info, I'll definitely look into the routine you suggested.
I really like the way you explained it, I understand the point that only A and B use the COM port to communicate to each other like you said, and that the suggestion of writing out a new Serial Monitor will be needed. But would B technically be the VS application used to send data and not a PC itself? Then it'd be that instances Serial Monitor as the display and not the Arduino's Serial Monitor?

Using the Arduino IDE to upload the sketch, and then the Serial Monitor is still technically A to B communication right?

The way I am thinking is, that I send data from the PC to the Arduino, using a VS application(Windows Forms). The data would be injected via the VS application the same way as if it were typed into the Serial Monitor, and the commands like the Write function would still be executed and sent back to the Serial Monitor of whatever was used to load the Arduino.
When using it on the Arduino IDE, the exchange is directly from Serial Monitor to the Arduino and back, so when I use a VS GUI to send it, I would have assumed the Arduino would be directly printing out to it's Serial Monitor.

So is the real difference that I'm using the Serial Monitor of the VS application to send the data and it's different than the Serial Monitor of the VS instance that loaded the code onto the Arduino?

I ran into the point you made about the char/string and int/byte value earlier when trying to write the array out and trying to fit the offset in.

Yeah, I really wish there were better ways of controlling it, but the Button is pretty convenient in my opinion since all the controls will be in 1 section rather than spread out and having to check multiple controls.