AI Object
 
This macro asks a question, then asks a follow-up in the same context by passing the existing handle back to Ask.
 
 
Option Explicit
 
Sub Main
    Dim aiHnd As Long
 
    ' First question
    aiHnd = AI.Ask("Give a SELECT query for all active customers in administration 1.", _
                   aiSQLCopilot)
    If aiHnd = 0 Then
        MsgBox "Submit failed: " & AI.LastErrorMessage, vbCritical
        Exit Sub
    End If
 
    Do
        DoEvents
    Loop Until AI.GetStatus(aiHnd) <> 1
 
    If AI.GetStatus(aiHnd) = 2 Then
        Debug.Print "--- First answer ---"
        Debug.Print AI.GetResultStr(aiHnd)
    End If
 
    ' Follow-up question on the same handle
    aiHnd = AI.Ask("Now sort that by last order date, descending.", , aiHnd)
    If aiHnd > 0 Then
        Do
            DoEvents
        Loop Until AI.GetStatus(aiHnd) <> 1
 
        If AI.GetStatus(aiHnd) = 2 Then
            Debug.Print "--- Follow-up answer ---"
            Debug.Print AI.GetResultStr(aiHnd)
        End If
    End If
 
    AI.CloseHandle aiHnd
End Sub
 
 
See Also
AskGetStatusGetResultStrGetResponseIdCloseHandle.