An ActiveX Control for Real-time Computer Control by Charles H. Huddleston and Douglas A. Troy Listing One Private Sub StartButton_Click() Call Lego1.StartLegos End Sub Private Sub StopButton_Click() Call Lego1.StopLegos End Sub Private Sub OnButton_Click() Call Lego1.TurnOn(port) End Sub Private Sub OffButton_Click() Call Lego1.TurnOff(port) End Sub Private Sub DirectionButton_Click() Dim d As Boolean If Direction = 1 Then d = True Else d = False Call Lego1.SetDirection(port, d) End Sub Private Sub ReverseButton_Click() Call Lego1.Reverse(port) End Sub Private Sub PowerButton_Click() Call Lego1.SetPower(port, Power) End Sub The following procedures handle events fired by the Lego Control: Private Sub Lego1_OnPress(ByVal port As Integer) Press(port).Value = 1 End Sub Private Sub Lego1_OnRelease(ByVal port As Integer) Press(port).Value = 0 End Sub Private Sub Lego1_OnTemperatureChange(ByVal port As Integer, ByVal temperature As Double) Temp(port) = temperature End Sub Private Sub Lego1_OnAngleChange(ByVal port As Integer, ByVal angle As Integer) AngleBox(port) = angle End Sub Listing Two