VERSION 5.00
Begin VB.Form frmCommand 
   Caption         =   "Command"
   ClientHeight    =   3390
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5070
   LinkTopic       =   "Form1"
   ScaleHeight     =   3390
   ScaleWidth      =   5070
   StartUpPosition =   3  'Windows の既定値
   Begin VB.Frame frmExecute 
      Caption         =   "Execute"
      Height          =   1095
      Left            =   120
      TabIndex        =   7
      Top             =   1560
      Width           =   4815
      Begin VB.CommandButton cmdExecute 
         Caption         =   "&Execute"
         Height          =   375
         Left            =   3600
         TabIndex        =   12
         Top             =   360
         Width           =   1095
      End
      Begin VB.TextBox txtResult 
         Height          =   270
         Left            =   1080
         TabIndex        =   11
         Text            =   "Text2"
         Top             =   720
         Width           =   2415
      End
      Begin VB.TextBox txtMode 
         BeginProperty DataFormat 
            Type            =   1
            Format          =   "0"
            HaveTrueFalseNull=   0
            FirstDayOfWeek  =   0
            FirstWeekOfYear =   0
            LCID            =   1041
            SubFormatType   =   1
         EndProperty
         Height          =   270
         Left            =   1080
         TabIndex        =   9
         Text            =   "Text1"
         Top             =   360
         Width           =   2415
      End
      Begin VB.Label lblResult 
         Caption         =   "Result :"
         Height          =   255
         Left            =   120
         TabIndex        =   10
         Top             =   720
         Width           =   615
      End
      Begin VB.Label lblMode 
         Caption         =   "Mode :"
         Height          =   255
         Left            =   120
         TabIndex        =   8
         Top             =   360
         Width           =   615
      End
   End
   Begin VB.Frame frmCommand 
      Caption         =   "Command"
      Height          =   1095
      Left            =   120
      TabIndex        =   1
      Top             =   120
      Width           =   4815
      Begin VB.CommandButton cmdAdd 
         Caption         =   "&Add"
         Height          =   375
         Left            =   3600
         TabIndex        =   6
         Top             =   600
         Width           =   1095
      End
      Begin VB.TextBox txtParam 
         Height          =   270
         Left            =   1080
         TabIndex        =   5
         Text            =   "Text2"
         Top             =   720
         Width           =   2415
      End
      Begin VB.TextBox txtCmd 
         Height          =   270
         Left            =   1080
         TabIndex        =   4
         Text            =   "Text1"
         Top             =   360
         Width           =   2415
      End
      Begin VB.Label lblParam 
         Caption         =   "Parameter :"
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   720
         Width           =   975
      End
      Begin VB.Label lblCommand 
         Caption         =   "Command :"
         Height          =   255
         Left            =   120
         TabIndex        =   2
         Top             =   360
         Width           =   855
      End
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   375
      Left            =   3720
      TabIndex        =   0
      Top             =   2880
      Width           =   1215
   End
End
Attribute VB_Name = "frmCommand"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private caoEng As CaoEngine
Private caoCtrl As CaoController
Private caoCmd As caoCommand

Private Sub Form_Load()
    Set caoEng = New CaoEngine
    Set caoCtrl = caoEng.Workspaces(0).AddController("RC1", "CaoProv.Dummy")
    
    txtCmd = ""
    txtParam = ""
    txtMode = ""
    txtResult = ""
    
    cmdRelease
End Sub

Private Sub Form_Unload(Cancel As Integer)
    ' CAOオブジェクトの解放
    cmdRelease
    
    Set caoCtrl = Nothing
    Set caoEng = Nothing
End Sub

Private Sub cmdAdd_Click()
    cmdRelease

    Set caoCmd = caoCtrl.AddCommand(txtCmd.Text, txtParam.Text)
    cmdExecute.Enabled = True
End Sub

Private Sub cmdExecute_Click()
    Dim varResult As Variant
    
    caoCmd.Execute (Val(txtMode))
    
    varResult = caoCmd.Result
    If varResult = 0 Then
        txtResult = "(EMPTY)"
    Else
        txtResult = varResult
    End If
End Sub

Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdRelease()
    If Not caoCmd Is Nothing Then
        caoCtrl.Commands.Remove caoCmd.index
        Set caoCmd = Nothing
    End If
    
    cmdExecute.Enabled = False
End Sub

