Option Strict Off Option Explicit On Friend Class frmMain Inherits System.Windows.Forms.Form Private velTextBoxChanging As Boolean Private Shared myTimer As New System.Windows.Forms.Timer() Private Sub Coast_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Coast.Click NdiCmd_Coast(wc132.handle) ' tell WheelCommander to stop moving End Sub Private Sub Go_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Go.Click Dim vel As Short vel = CShort(Velocity.Text) If NdiCmd_SetVelocity(wc132.handle, vel) <> 1 Then ' pass velocity value from form to WheelCommander; only needed if user never set the velocity MsgBox("Error setting velocity!") Else If NdiCmd_Go(wc132.handle) <> 1 Then ' tell WheelCommander to start using current velocity setting MsgBox("Error on Go!") End If End If End Sub Private Sub Velocity_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Velocity.ValueChanged Dim vel As Short vel = CShort(Velocity.Text) If NdiCmd_SetVelocity(wc132.handle, vel) <> 1 Then ' pass velocity value from form to WheelCommander MsgBox("Error on SetVelocity!") End If End Sub Private Sub VelScroll_Change(ByVal newScrollValue As Integer) If velTextBoxChanging = False Then Velocity.Text = CStr(newScrollValue) End If End Sub Public Sub mnuHelpAbout_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuHelpAbout.Click VB6.ShowForm(frmAbout, VB6.FormShowConstants.Modal, Me) End Sub Public Sub mnuViewOptions_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuViewOptions.Click VB6.ShowForm(frmOptions, VB6.FormShowConstants.Modal, Me) End Sub Public Sub mnuViewRefresh_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuViewRefresh.Click MsgBox("Add 'mnuViewRefresh_Click' code.") End Sub Public Sub mnuViewStatusBar_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuViewStatusBar.Click mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked sbStatusBar.Visible = mnuViewStatusBar.Checked End Sub Public Sub mnuFileExit_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnuFileExit.Click 'unload the form Me.Close() End Sub Private Sub VelScroll_Scroll(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.ScrollEventArgs) Select Case eventArgs.Type Case System.Windows.Forms.ScrollEventType.EndScroll VelScroll_Change(eventArgs.NewValue) End Select End Sub Private Sub OnTick(ByVal myObject As Object, ByVal myEventArgs As EventArgs) Dim voltage As Double Dim dist As Integer Dim ang As Integer Dim vel As Integer Dim rot As Integer Dim trunc As String If NdiCmd_ReadAIO(wc132.handle, 6, voltage) = 1 Then trunc = Str(voltage * 40.01 / 10) DigitalSupply.Text = trunc.Remove(5, trunc.Length - 5) End If If NdiCmd_ReadAIO(wc132.handle, 7, voltage) = 1 Then trunc = Str(voltage * 100.09 / 10) MotorSupply.Text = trunc.Remove(5, trunc.Length - 5) End If If NdiCmd_GetDist(wc132.handle, dist) = 1 Then Distance.Text = Str(dist) End If If NdiCmd_GetAngle(wc132.handle, ang) = 1 Then Angle.Text = Str(ang) End If If NdiCmd_GetVelocity(wc132.handle, vel) = 1 Then CurVelocity.Text = Str(vel) End If If NdiCmd_GetRotation(wc132.handle, rot) = 1 Then RotationRate.Text = Str(rot) End If End Sub Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Left = VB6.TwipsToPixelsX(CSng(GetSetting(My.Application.Info.Title, "Settings", "MainLeft", CStr(1000)))) Me.Top = VB6.TwipsToPixelsY(CSng(GetSetting(My.Application.Info.Title, "Settings", "MainTop", CStr(1000)))) Me.Width = VB6.TwipsToPixelsX(CSng(GetSetting(My.Application.Info.Title, "Settings", "MainWidth", CStr(6500)))) Me.Height = VB6.TwipsToPixelsY(CSng(GetSetting(My.Application.Info.Title, "Settings", "MainHeight", CStr(6500)))) AddHandler myTimer.Tick, AddressOf OnTick myTimer.Interval = 500 myTimer.Start() End Sub Private Sub frmMain_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed If Me.WindowState <> System.Windows.Forms.FormWindowState.Minimized Then SaveSetting(My.Application.Info.Title, "Settings", "MainLeft", CStr(VB6.PixelsToTwipsX(Me.Left))) SaveSetting(My.Application.Info.Title, "Settings", "MainTop", CStr(VB6.PixelsToTwipsY(Me.Top))) SaveSetting(My.Application.Info.Title, "Settings", "MainWidth", CStr(VB6.PixelsToTwipsX(Me.Width))) SaveSetting(My.Application.Info.Title, "Settings", "MainHeight", CStr(VB6.PixelsToTwipsY(Me.Height))) End If End Sub End Class