Hello I'm having an issue with a serial connection program. It connects a motor controller to a computer via RS232.

Here is the code:

VB Code:
  1. Public Class Form1
  2.     Dim COM1 As IO.Ports.SerialPort = My.Computer.Ports.OpenSerialPort("COM1", 38400, IO.Ports.Parity.Odd, 7, IO.Ports.StopBits.One)
  3.     Dim Ring_Vel As Integer = 1
  4.  
  5.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  6.         'First run setup
  7.         COM1.WriteLine("1PW" & vbCr & vbCr)
  8.         COM1.WriteLine("1RSF" & vbCr)
  9.         COM1.WriteLine("1AC=100000" & vbCr)
  10.         COM1.WriteLine("1VL=" & Ring_Vel & vbCr)
  11.         VScrollBar1.Value = Ring_Vel
  12.         Label3.Text = Ring_Vel
  13.     End Sub
  14.  
  15.  
  16.     Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
  17.         'Speed Controller
  18.         Ring_Vel = VScrollBar1.Value * 1000
  19.         COM1.WriteLine("1VL=" & Ring_Vel & vbCr)
  20.         If Button1.Enabled = False Then COM1.WriteLine("1RFN" & vbCr)
  21.         Label3.Text = VScrollBar1.Value
  22.     End Sub
  23.  
  24.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  25.         'Start Button
  26.         Button1.Enabled = False
  27.         Button2.Enabled = True
  28.         COM1.WriteLine("1RFN" & vbCr)
  29.     End Sub
  30.  
  31.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  32.         'Stop Button
  33.         Button1.Enabled = True
  34.         Button2.Enabled = False
  35.         COM1.WriteLine("1ST" & vbCr)
  36.     End Sub
  37. End Class

If I change the VScroll1 quickly and often I get this error:
The I/O operation has been aborted because of either a thread exit or an application request.


Why is it doing this? I tried to put the COM1.WriteLine on a timer (.5 sec) so it doesnt overload the buffers or something. And it will still do it.

I dont understand bc I have another program that has a loop, and every cycle of the loop it sends something to the unit. It was able to reach nearly 30 sends per second.