I would like to use the StringBuilder module with VB6.

I note that I have to use .ToString to convert StringBuilder contents.

Looking at the mod_thinbasic.bas file, I see no string type;

Public Const VarSubType_Byte = 1
Public Const VarSubType_Integer = 2
Public Const VarSubType_Word = 3
Public Const VarSubType_DWord = 4
Public Const VarSubType_Long = 5
Public Const VarSubType_Quad = 6
Public Const VarSubType_Single = 7
Public Const VarSubType_Double = 8
Public Const VarSubType_Currency = 9
Public Const VarSubType_Ext = 10
Public Const VarSubType_Variant = 50
for use with the thinBasic_AddVariable_VB function.

Thus, I see that I will have to declare the variable as Variant from VB6,
and do converstion to string,
for use with StringBuilder,
then back to Variant for VB6.

So, I started my quest by creating a test script;
uses "Console"
Dim vStuff as Variant
Dim SStuff as String

vStuff = "Test"                              'Variant
PrintL "TypeOf(vStuff) : " + TypeOf(vStuff)  'Variant.Variant
SStuff = vStuff                              'String equals Variant
PrintL "TypeOf(sStuff) : " + TypeOf(sStuff)  'String.String
PrintL "String : " + sStuff                  'Test
PrintL "Variant: " + vStuff                  'Test
...which produces...

TypeOf(vStuff) : Variant.Variant
TypeOf(sStuff) : String.String
String : Test
Variant: Test
So far, so good.

Next, get this working with VB6;
Attribute VB_Name = "mod_Main"
Option Explicit
Sub Main()
    Dim hScript As Long    'handle to thinBasic Script
    Dim sScript As String  'thinBasic Script
    Dim hRun As Long       'thinBasic_Run
    
    Dim sStuff As String   'Declare String Variable for thinBasic Script
    Dim vStuff As Variant  'Declare Variant Variable for thinBasic Script
    
    Dim lRet As Long       'thinBasic_AddVariable_VB
    Dim sResult As String  'thinBasic Script Output
    
    Const thinBasic_BufferType_IsFile = 0
    Const thinBasic_BufferType_IsScript = 1

    On Error GoTo CatchError
  
    'Begin thinBasic Script
    sScript = vbNullString
    sScript = "DIM sStuff as String" + vbCrLf
    sScript = sScript + "DIM vStuff as Variant" + vbCrLf
    
    sScript = sScript + "sStuff = " + Chr$(34) + "Test" + Chr$(34) + vbCrLf
    sScript = sScript + "vStuff = sStuff"
    'End   thinBasic Script

    If Len(sScript) Then
      hScript = thinBasic_Init(0, App.hInstance, "thinbasic")
      If hScript = 0 Then
            
        lRet = thinBasic_AddVariable_VB("vStuff", "", 0, VarSubType_Variant, VarPtr(vStuff))
            
        hRun = thinBasic_Run(hScript, sScript, thinBasic_BufferType_IsScript, 1 Or 2, False, False, False, 1, False)
        
        sResult = sResult + Time$ + " : String: " + sStuff + " : Variant: " + vStuff
           
        Debug.Print sScript
        Debug.Print sResult
        Debug.Print
            
        thinBasic_Release (hScript)
      End If
    Else
      Debug.Print "Where's the code for the thinBasic Script?"
    End If
    
    Exit Sub

CatchError:
    MsgBox "Error occurred: " + Err.Description
    Resume Next
Return

End Sub
...which produces...

DIM sStuff as String
DIM vStuff as Variant
sStuff = "Test"
vStuff = sStuff
11:04:11 : String:  : Variant:
Nothing is returned from thinBasic to VB6.

As there is no Public Const VarSubType_String,
how do I send a variant from VB6 to thinBasic,
convert it to a string,
do something with the string,
convert the string to a variant,
and send it back to VB6?

Thanks from Joe