www.pudn.com > the PC Host examples .zip > StepperMotor.frm


VERSION 5.00 
Begin VB.Form DisplayWindow  
   BackColor       =   &H00FF8080& 
   Caption         =   "USB Design By Example: Thermometer Examples" 
   ClientHeight    =   5595 
   ClientLeft      =   60 
   ClientTop       =   345 
   ClientWidth     =   8475 
   FillColor       =   &H00FFFFFF& 
   FillStyle       =   0  'Solid 
   LinkTopic       =   "Form1" 
   ScaleHeight     =   5595 
   ScaleWidth      =   8475 
   StartUpPosition =   3  'Windows Default 
   Begin VB.TextBox Clockwise  
      Alignment       =   2  'Center 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   13.5 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   495 
      Left            =   5760 
      TabIndex        =   2 
      Text            =   "0" 
      Top             =   1920 
      Width           =   1095 
   End 
   Begin VB.TextBox CounterClockwise  
      Alignment       =   2  'Center 
      BeginProperty Font  
         Name            =   "MS Sans Serif" 
         Size            =   13.5 
         Charset         =   0 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   495 
      Left            =   1560 
      TabIndex        =   1 
      Text            =   "0" 
      Top             =   1920 
      Width           =   1095 
   End 
   Begin VB.Image Image3  
      Height          =   1965 
      Left            =   3240 
      Picture         =   "StepperMotor.frx":0000 
      Top             =   1440 
      Width           =   4260 
   End 
   Begin VB.Image Image2  
      Height          =   1965 
      Left            =   960 
      Picture         =   "StepperMotor.frx":0270 
      Top             =   1440 
      Width           =   4275 
   End 
   Begin VB.Image Image1  
      Height          =   2625 
      Left            =   2400 
      Picture         =   "StepperMotor.frx":04E0 
      Top             =   2520 
      Width           =   3270 
   End 
   Begin VB.Label Title  
      Alignment       =   2  'Center 
      BackStyle       =   0  'Transparent 
      Caption         =   "Stepper Motor Control" 
      BeginProperty Font  
         Name            =   "Arial Rounded MT Bold" 
         Size            =   24 
         Charset         =   0 
         Weight          =   700 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      ForeColor       =   &H00FFFFFF& 
      Height          =   1095 
      Left            =   0 
      TabIndex        =   0 
      Top             =   360 
      Width           =   8535 
   End 
End 
Attribute VB_Name = "DisplayWindow" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Private Sub Form_Load() 
Clockwise.Text = "0": CounterClockwise.Text = "0" 
End Sub 
Private Sub Clockwise_KeyPress(KeyAscii%) 
If KeyAscii = 13 Then Call SendClockwiseCommand ' Wait until a value is entered 
If (KeyAscii < Asc("0")) Or (KeyAscii > Asc("9")) Then KeyAscii = 0 ' Only accept digits 
End Sub 
Private Sub CounterClockwise_KeyPress(KeyAscii%) 
If KeyAscii = 13 Then Call SendCounterClockwiseCommand ' Wait until a value is entered 
If (KeyAscii < Asc("0")) Or (KeyAscii > Asc("9")) Then KeyAscii = 0 ' Only accept digits 
End Sub 
Private Sub SendClockwiseCommand() 
Dim Buffer(2) As Byte 
' Need to send a turn command to the IO device 
Counter% = Val(Clockwise.Text): CounterClockwise.Text = "0" 
Buffer(0) = 0 ' Clockwise command 
Buffer(1) = Counter% And &HFF: Buffer(2) = ((Counter% And &HFF00) / 16) And &HFF 
'Call WriteUSBdevice(AddressFor(Buffer(0)), 3) 
End Sub 
Private Sub SendCounterClockwiseCommand() 
Dim Buffer(2) As Byte 
' Need to send a turn command to the IO device 
Counter% = Val(CounterClockwise.Text): Clockwise.Text = "0" 
Buffer(0) = 1 ' CounterClockwise command 
Buffer(1) = Counter% And &HFF: Buffer(2) = ((Counter% And &HFF00) / 16) And &HFF 
'Call WriteUSBdevice(AddressFor(Buffer(0)), 3) 
End Sub