Using visual studio to control project 10 Zoetrope

I am working on a project that is going to require me to write code in visual basic that will in turn communicate with the Arduino Uno. What the Arduino will control is a DC motor. Without any analog inputs or switches connected to the Arduino.

This is the code i have so far. I was working off of another code for a servo motor, but have not managed to get very far. I would like to have two buttons that would control the direction and then a switch to power it on and a track bar to control the speed.

Imports System.IO
Imports System.IO.Ports
Imports System.Threading

Public Class Form1

Shared _continue As Boolean
Shared _serialPort As SerialPort

Dim on0ffSwitchState As Integer = 0
Dim previousOnOffSwitchState As Integer = 0
Dim directionSwitchState As Integer = 0
Dim previousDirectionSwitchState As Integer = 0
Dim motorEnabled As Integer = 0
Dim motorSpeed As Integer = 0
Dim motorDirection = 1

Private Sub TrackBar1_MouseUp(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.MouseUp

If on0ffSwitchState < 10 Then
SerialPort1.Open()
SerialPort1.Write(0)
SerialPort1.Write(0)
SerialPort1.Write(on0ffSwitchState)
SerialPort1.Write(motorEnabled)
Thread.Sleep(500)
SerialPort1.Close()

ElseIf on0ffSwitchState < 100 Then

SerialPort1.Open()
SerialPort1.Write(0)
SerialPort1.Write(on0ffSwitchState)
SerialPort1.Write(motorEnabled)
Thread.Sleep(500)
SerialPort1.Close()

Else

SerialPort1.Open()
SerialPort1.Write(on0ffSwitchState)
SerialPort1.Write(motorEnabled)
Thread.Sleep(500)
SerialPort1.Close()
End If

End Sub

Private Sub TrackBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged

on0ffSwitchState = CInt(TrackBar1.Value)
lblValue.Text = on0ffSwitchState
Meter1.Value = TrackBar1.Value
Gauge1.Value = TrackBar1.Value
Gauge1.Maximum = 180
Meter1.Maximum = 180

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

SerialPort1.Close()
SerialPort1.PortName = “COM4” 'change com port to match your Arduino port
SerialPort1.BaudRate = 9600
SerialPort1.DataBits = 8
SerialPort1.Parity = Parity.None
SerialPort1.StopBits = StopBits.One
SerialPort1.Handshake = Handshake.None
SerialPort1.Encoding = System.Text.Encoding.Default 'very important!

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SerialPort1.Close()

Me.Close()
End Sub

Private Sub Meter1_Load(sender As Object, e As EventArgs) Handles Meter1.Load

End Sub

Private Sub Gauge1_Load(sender As Object, e As EventArgs) Handles Gauge1.Load

End Sub

Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

End Sub
End Class

this is the Arduino code for project 10 that I have been trying to manipulate to work with visual studio.

const int controlPin1 = 2; // connected to pin 7 on the H-bridge
const int controlPin2 = 3; // connected to pin 2 on the H-bridge
const int enablePin = 9; // connected to pin 1 on the H-bridge

// create some variables to hold values from your inputs
int onOffSwitchState = 0; // current state of the On/Off switch
int previousOnOffSwitchState = 0; // previous position of the on/off switch
int directionSwitchState = 0; // current state of the direction switch
int previousDirectionSwitchState = 0; // previous state of the direction switch

int motorEnabled = 0; // Turns the motor on/off
int motorSpeed = 0; // speed of the motor
int motorDirection = 1; // current direction of the motor

void setup(){
// intialize the inputs and outputs

pinMode(controlPin1, OUTPUT);
pinMode(controlPin2, OUTPUT);
pinMode(enablePin, OUTPUT);

// pull the enable pin LOW to start
digitalWrite(enablePin, LOW);
}

void loop(){
// read the value of the on/off switch

delay(1);

// read the value of the direction switch

// read the value of the pot and divide by 4 to get
// a value that can be used for PWM

// if the on/off button changed state since the last loop()
if(onOffSwitchState != previousOnOffSwitchState){
// change the value of motorEnabled if pressed
if(onOffSwitchState == HIGH){
motorEnabled = !motorEnabled;
}
}

// if the direction button changed state since the last loop()
if (directionSwitchState != previousDirectionSwitchState) {
// change the value of motorDirection if pressed
if (directionSwitchState == HIGH) {
motorDirection = !motorDirection;
}
}

// change the direction the motor spins by talking
// to the control pins on the H-Bridge
if (motorDirection == 1) {
digitalWrite(controlPin1, HIGH);
digitalWrite(controlPin2, LOW);
}
else {
digitalWrite(controlPin1, LOW);
digitalWrite(controlPin2, HIGH);
}

// if the motor is supposed to be on
if (motorEnabled == 1) {
// PWM the enable pin to vary the speed
analogWrite(enablePin, motorSpeed);
}
else { // if the motor is not supposed to be on
//turn the motor off
analogWrite(enablePin, 0);
}
// save the current On/Offswitch state as the previous
previousDirectionSwitchState = directionSwitchState;
// save the current switch state as the previous
previousOnOffSwitchState = onOffSwitchState;
}

At this point have been just attempting to get the motor to start up and then move onto the rest of it so if anyone has any helpful hints to point me in the right direction that would be great. Thank you very much for the time you put into reading this post and supplying any information.