diff -rup basic/inc/sbx.hxx basic/inc/sbx.hxx
--- basic/inc/sbx.hxx	2007-02-06 16:57:33.000000000 +0000
+++ basic/inc/sbx.hxx	2007-02-06 18:05:06.000000000 +0000
@@ -265,6 +265,7 @@ class SbxDimArray : public SbxArray
 	SbxDim* pFirst, *pLast;         // Links fuer Dimension-Tabelle
 	short   nDim;                   // Anzahl Dimensionen
 	void   AddDimImpl32( INT32, INT32, BOOL bAllowSize0 );
+	bool mbHasFixedSize;
 protected:
 	USHORT  Offset( const short* );
 	UINT32  Offset32( const INT32* );
@@ -304,6 +305,8 @@ public:
 	void   AddDim32( INT32, INT32 );
 	void   unoAddDim32( INT32, INT32 );
 	BOOL   GetDim32( INT32, INT32&, INT32& ) const;
+	bool hasFixedSize() { return mbHasFixedSize; };
+	void setHasFixedSize( bool bHasFixedSize ) {mbHasFixedSize = bHasFixedSize; };
 };
 
 #endif
diff -rup basic/source/comp/dim.cxx basic/source/comp/dim.cxx
--- basic/source/comp/dim.cxx	2007-01-25 16:52:43.000000000 +0000
+++ basic/source/comp/dim.cxx	2007-02-06 17:45:25.000000000 +0000
@@ -445,7 +445,14 @@ void SbiParser::DefVar( SbiOpcode eOp, B
 				{
 					SbiExpression aExpr( this, *pDef, NULL );
 					aExpr.Gen();
-					aGen.Gen( _ERASE );
+					if ( bVBASupportOn )
+						// delete the array but
+						// clear the variable ( this
+						// allows the processing of
+						// the param to happen as normal without errors ( ordinary ERASE just clears the array )
+						aGen.Gen( _ERASE_CLEAR );
+					else
+						aGen.Gen( _ERASE );
 				}
 				else if( eOp == _REDIMP )
 				{
diff -rup basic/source/inc/opcodes.hxx basic/source/inc/opcodes.hxx
--- basic/source/inc/opcodes.hxx	2007-01-25 16:52:43.000000000 +0000
+++ basic/source/inc/opcodes.hxx	2007-02-06 17:46:13.000000000 +0000
@@ -99,6 +99,7 @@ enum SbiOpcode {
 	_REDIMP_ERASE,		// Copies array to be later used by REDIM PRESERVE before erasing it
 	_INITFOREACH,
 	_VBASET,            // VBA-like Set
+	_ERASE_CLEAR,       // Erase array and clear variable
 	SbOP0_END,
 
 	// Alle Opcodes mit einem Operanden
diff -rup basic/source/inc/runtime.hxx basic/source/inc/runtime.hxx
--- basic/source/inc/runtime.hxx	2007-01-25 16:52:44.000000000 +0000
+++ basic/source/inc/runtime.hxx	2007-02-06 17:46:13.000000000 +0000
@@ -454,7 +454,7 @@ class SbiRuntime
 	void StepNOERROR(), StepCHANNEL(),  StepCHANNEL0(),	StepPRINT();
 	void StepPRINTF(),	StepWRITE(),    StepRENAME(),   StepPROMPT();
 	void StepRESTART(), StepEMPTY(),    StepLEAVE();
-	void StepLSET(),	StepRSET(),		StepREDIMP_ERASE();
+	void StepLSET(),	StepRSET(),		StepREDIMP_ERASE(), 	StepERASE_CLEAR();
 	// Alle Opcodes mit einem Operanden
 	void StepLOADNC( UINT32 ),  StepLOADSC( UINT32 ),   StepLOADI( UINT32 );
 	void StepARGN( UINT32 ),	StepBASED( UINT32 ),	StepPAD( UINT32 );
diff -rup basic/source/runtime/runtime.cxx basic/source/runtime/runtime.cxx
--- basic/source/runtime/runtime.cxx	2007-02-05 18:10:26.000000000 +0000
+++ basic/source/runtime/runtime.cxx	2007-02-06 18:22:05.000000000 +0000
@@ -296,6 +297,7 @@ SbiRuntime::pStep0 SbiRuntime::aStep0[] 
 	&SbiRuntime::StepREDIMP_ERASE,// Copy array object for REDIMP
 	&SbiRuntime::StepINITFOREACH,// Init for each loop
 	&SbiRuntime::StepVBASET,// vba-like set statement
+	&SbiRuntime::StepERASE_CLEAR,// vba-like set statement
 };
 
 SbiRuntime::pStep1 SbiRuntime::aStep1[] = {	// Alle Opcodes mit einem Operanden
diff -rup basic/source/runtime/step0.cxx basic/source/runtime/step0.cxx
--- basic/source/runtime/step0.cxx	2007-02-06 16:57:33.000000000 +0000
+++ basic/source/runtime/step0.cxx	2007-02-06 18:06:39.000000000 +0000
@@ -632,6 +632,8 @@ void SbiRuntime::DimImpl( SbxVariableRef
 				if( ub < lb )
 					Error( SbERR_OUT_OF_RANGE ), ub = lb;
 				pArray->AddDim32( lb, ub );
+				if ( lb != ub )
+					pArray->setHasFixedSize( true );
 			}
 		}
 		else
@@ -800,27 +802,51 @@ void SbiRuntime::StepREDIMP_ERASE()
 		refVar->SetType( SbxEMPTY );
 }
 
+void lcl_clearImpl( SbxVariableRef& refVar, SbxDataType& eType )
+{
+	USHORT nSavFlags = refVar->GetFlags();
+	refVar->ResetFlag( SBX_FIXED );
+	refVar->SetType( SbxDataType(eType & 0x0FFF) );
+	refVar->SetFlags( nSavFlags );
+	refVar->Clear();
+}
 
-// Variable loeschen
-// TOS = Variable
-
-void SbiRuntime::StepERASE()
+void lcl_eraseImpl( SbxVariableRef& refVar, bool bVBAEnabled )
 {
-	SbxVariableRef refVar = PopVar();
 	SbxDataType eType = refVar->GetType();
 	if( eType & SbxARRAY )
 	{
+		if ( bVBAEnabled )
+		{
+			SbxBase* pElemObj = refVar->GetObject();
+			SbxDimArray* pDimArray = PTR_CAST(SbxDimArray,pElemObj);
+			bool bClearValues = true;
+			if( pDimArray )
+			{
+				if ( pDimArray->hasFixedSize() )
+				{
+					// Clear all Value(s)
+					pDimArray->SbxArray::Clear();
+					bClearValues = false;
+				}
+				else
+					pDimArray->Clear(); // clear Dims
+			}
+			if ( bClearValues )
+			{
+				SbxArray* pArray = PTR_CAST(SbxArray,pElemObj);
+				if ( pArray )
+					pArray->Clear();
+			}				
+		}
+		else
 		// AB 2.4.1996
 		// Arrays haben bei Erase nach VB ein recht komplexes Verhalten. Hier
 		// werden zunaechst nur die Typ-Probleme bei REDIM (#26295) beseitigt:
 		// Typ hart auf den Array-Typ setzen, da eine Variable mit Array
 		// SbxOBJECT ist. Bei REDIM entsteht dann ein SbxOBJECT-Array und
 		// der ursruengliche Typ geht verloren -> Laufzeitfehler
-		USHORT nSavFlags = refVar->GetFlags();
-		refVar->ResetFlag( SBX_FIXED );
-		refVar->SetType( SbxDataType(eType & 0x0FFF) );
-		refVar->SetFlags( nSavFlags );
-		refVar->Clear();
+			lcl_clearImpl( refVar, eType );
 	}
 	else
 	if( refVar->IsFixed() )
@@ -829,6 +855,23 @@ void SbiRuntime::StepERASE()
 		refVar->SetType( SbxEMPTY );
 }
 
+// Variable loeschen
+// TOS = Variable
+
+void SbiRuntime::StepERASE()
+{
+	SbxVariableRef refVar = PopVar();
+	lcl_eraseImpl( refVar, bVBAEnabled );
+}
+
+void SbiRuntime::StepERASE_CLEAR()
+{
+	SbxVariableRef refVar = PopVar();
+	lcl_eraseImpl( refVar, bVBAEnabled );
+	SbxDataType eType = refVar->GetType();
+	lcl_clearImpl( refVar, eType );
+}
+
 // Einrichten eines Argvs
 // nOp1 bleibt so -> 1. Element ist Returnwert
 
diff -rup basic/source/sbx/sbxarray.cxx basic/source/sbx/sbxarray.cxx
--- basic/source/sbx/sbxarray.cxx	2007-02-06 16:57:33.000000000 +0000
+++ basic/source/sbx/sbxarray.cxx	2007-02-06 18:05:06.000000000 +0000
@@ -40,6 +40,7 @@
 #include <tools/stream.hxx>
 #endif
 #include "sbx.hxx"
+#include "runtime.hxx"
 #include <vector>
 using namespace std;
 
@@ -593,7 +593,7 @@ void SbxArray::PutDirect( SbxVariable* p
 //
 //////////////////////////////////////////////////////////////////////////
 
-SbxDimArray::SbxDimArray( SbxDataType t ) : SbxArray( t )
+SbxDimArray::SbxDimArray( SbxDataType t ) : SbxArray( t ), mbHasFixedSize( false )
 {
 	pFirst = pLast = NULL;
 	nDim = 0;
@@ -618,6 +618,7 @@ SbxDimArray& SbxDimArray::operator=( con
 			AddDim32( p->nLbound, p->nUbound );
 			p = p->pNext;
 		}
+		this->mbHasFixedSize = rArray.mbHasFixedSize;
 	}
 	return *this;
 }
@@ -793,7 +794,7 @@ void SbxDimArray::Put32( SbxVariable* p,
 
 UINT32 SbxDimArray::Offset32( SbxArray* pPar )
 {
-	if( nDim == 0 || !pPar )
+	if( nDim == 0 || !pPar || ( ( nDim != ( pPar->Count() - 1 ) ) && SbiRuntime::isVBAEnabled() ) )
 	{
 		SetError( SbxERR_BOUNDS ); return 0;
 	}
