应用程序vb6到应用程序vb.net [英] Application vb6 to Application vb.net

查看:57
本文介绍了应用程序vb6到应用程序vb.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Public apExcel As Microsoft.Office.Interop.Excel.Application = DirectCast(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)

Public Sub LoadSpreadsheet(ByRef cSheetType As String)

apExcel.Workbooks.Open(strSheetName)

End Sub



有时apExcelNothing,并在尝试打开时创建NullReferenceException
有什么方法可以延迟或通过其他方法解决问题.谢谢.



sometimes apExcel is Nothing and creates NullReferenceException when trying to open
is there any way delaying or some other solution thanks..

推荐答案

不要在全局范围内创建引用.您应该在需要时创建Excel.Application,并在不使用时关闭并处置.
Don''t create the reference in a global scope. You should be creating the Excel.Application when needed and closing and disposing when not in use.


通过this-
进行操作
将VB项目迁移到VB.NET [
go through this-

Migrating a VB Project to VB.NET[^]


这篇关于应用程序vb6到应用程序vb.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆