Hello,
I have made a migration from VB 6.0 to VB.NET and noticed a great speed
change when I access (from VB) to Excel Cells (same problem to write Visio
formulas from VB).
The same code takes 21 seconds in VB 6.0 and 54 seconds in VB.NET (see below)
1. Is that fact well known?
2. How to solve the problem?
3. Can we expect change in latter version?
---------------------------------------------------------
In VB 6.0 the following code is executed in 21 seconds in VB 6.0 and 54
seconds in VB.NET on the same PC:
Dim I As Integer
Dim J As Integer
Dim myExcelApp As Excel.Application
Dim objBook As Excel.Workbook
Dim objSheet As Excel.Worksheet
Dim dStart As Double
Set myExcelApp = CreateObject("Excel.Application")
Set objBook = myExcelApp.Workbooks.Add("D:\toto.xls")
Set objSheet = objBook.Worksheets("Sheet1")
dStart = Timer
For I = 1 To 60
For J = 1 To 100
objSheet.Cells(J, I).Value = 1
Next J
Next I
MsgBox ("This operation took : " & CStr(CInt(Timer - dStart)) & "
seconds")
--------------------------------------------------------------------------------------
Thank you
Philippe
PS : To make yourself the experience on VB.NET, just replace in this VB 6.0
code "Timer" by "Microsoft.VisualBasic.Timer"
Mattias Sj?gren - 27 Sep 2004 22:21 GMT
Philippe,
>1. Is that fact well known?
Well all managed<->native transitions cause some overhead.
>2. How to solve the problem?
Keep the loop code in native code (VB6) and call it from VB.NET.
>3. Can we expect change in latter version?
I doubt it.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.