Control servo with Visual Basic 2008

I changed your code so I thought it would work, but it didn't. This is my Arduino code now:

int select;
int val;
int val2;
int servoValue = 0;
char inData[12];
int index = 0;
bool started = false;
bool ended = false;
int pos;

#include <Servo.h> 
 
Servo myservo;

void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 

void loop()
{
   if(Serial.available() > 0)
  {
     while(Serial.available() > 0)
     {
        char aChar = Serial.read();
        if(aChar == '<')
        {
           index = 0;
           inData[index] = '\0'; // Null out the array
           started = true;
           ended = false;
        }
        if(aChar != '>' && started && !ended)
        {
           inData[index] = aChar;
           index++;
           inData[index] = '\0';
        }
        if(aChar == '>')
        {
            ended = true;
            started = false;
        }
          if(aChar == ':')
          {
            select = pos;
            pos = 0;
            val = 1;
          }
        if(ended && !started)
        {
            servoValue = atoi(inData);
            myservo.write(pos);
            delay(15);
            ended = false; // Set up for the next packet
        }
          else{
            select = Serial.read();
            val2 = Serial.read();
            if(val = 1){
              val2 = Serial.read();
              val2 * 100;
              pos = val2;
            }
            else if(val = 2){
              val2 = Serial.read();
              val2 * 10;
              pos = pos + val2;
            }
            else if(val = 3){
              val2 = Serial.read();
              pos = pos + val2;
              val = 0;
            }
          }
     }
  }
}

And this is my Visual Basic 2008 code:

 Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
        Dim value As Integer
        SerialPort1.Write("<")
        If TrackBar1.Value.ToString.Count = 1 Then
            SerialPort1.Write("1")
            SerialPort1.Write(":")
            SerialPort1.Write(TrackBar1.Value)
        ElseIf TrackBar1.Value.ToString.Count = 2 Then
            SerialPort1.Write("2")
            SerialPort1.Write(":")
            SerialPort1.Write(TrackBar1.Value.ToString.First)
            SerialPort1.Write(TrackBar1.Value.ToString.Last)
        ElseIf TrackBar1.Value.ToString.Count = 3 Then
            SerialPort1.Write("3")
            SerialPort1.Write(":")
            SerialPort1.Write(TrackBar1.Value.ToString.First)
            value = TrackBar1.Value - 100
            SerialPort1.Write(value - Val(TrackBar1.Value.ToString.Last))
            SerialPort1.Write(TrackBar1.Value.ToString.Last)
        End If
        SerialPort1.Write(">")
    End Sub