I am attempting to read the position of a servo (channel 0) using the following code in VB 2010 with the minimaestro 6, however I am getting the exception appear in the message box when button 1 is clicked as opposed to the servo position data.
‘Index is out of range of the array’
Does anyone know why this might be?
Thanks
hdavy1234
Code:
[code]Public Class MainWindow
Public Property Stack As Object
Dim st As Short()
''' <summary>
''' Attepts to get variables from the stack
''' </summary>
Public Sub TryGetVariables()
Try
Using device As Usc = connectToDevice() ' Find a device and temporarily connect.
device.getVariables(st)
MessageBox.Show(st(0).ToString())
' device.Dispose() is called automatically when the "Using" block ends,
' allowing other functions and processes to use the device.
End Using
Catch exception As Exception ' Handle exceptions by displaying them to the user.
displayException(exception)
End Try
End Sub
Public Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TryGetVariables()
TextBox2.Text = st(0).ToString
End Sub[/code]