Serialport writeline textbox error
<p>I use virtual COM ports for testing my program. I want to Serial Write with COM8 and Serial read with COM9. When a want to write the values from textbox1, i get this error:</p>

<pre><code>IOException was unhandled (The parameter is incorrect) 
</code></pre>

<p>How do i get rid of this?</p>

<pre><code>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;

namespace Flowerpod_User_Interface
{
    public partial class Form1 : Form
    {
        public Form1()
        {

            InitializeComponent();
            // show list of valid COM ports
            foreach (string s in System.IO.Ports.SerialPort.GetPortNames())
            {
                comboBox1.Items.Add(s);
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (serialPort1.IsOpen)
            {
                serialPort1.WriteLine(textBox1.Text);


            }
            else
            {
                MessageBox.Show("SerialPort1 is not open");
            }
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void Connect_Click(object sender, EventArgs e)
        {
            if (!serialPort1.IsOpen)
            {
                serialPort1.PortName = comboBox1.SelectedItem.ToString();

                serialPort1.Open();

                textBox3.Text = "Open"; 
            }

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            Random slumpGenerator = new Random();
            // Or whatever limits you want... Next() returns a double
            int tal = slumpGenerator.Next(1000, 10000);
            textBox1.Text = tal.ToString();
        }

        private void textBox4_TextChanged(object sender, EventArgs e)
        {

        }




     private void serialPort1_DataReceived(object sender,SerialDataReceivedEventArgs e)
        {

        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (!serialPortRead.IsOpen)
            {
                serialPort1.PortName = "COM9";

                serialPortRead.Open();

                textBox4.Text = serialPortRead.ReadLine();                 
            }
        }
    }
}
</code></pre>
