本文介绍了未设置对象引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 有人能指出我在这里犯的小错误吗? Public Sub InitBestand() Dim Programma As Application gstrBestand = Programma.UserAppDataPath 如果Strings.Right(gstrBestand,1)<> " \"然后gstrBestand& =" \" gstrBestand& =" beginner.txt" End Sub 错误是: 类型''System.NullReferenceException''的未处理异常发生在 system.windows.forms.dll 附加信息:对象引用未设置为 对象的实例。 出错的行是: gstrBestand = Programma.UserAppDataPath 我认为做Dim Programma As Application已经足够了 显然不是吗? - localghost 解决方案 - 最诚挚的问候 - OHM O_H_M {at} BTInternet {dot} com * localhost< lo ******* @ localdomain.org> scripsit: 跳过第1并且使用它: \\\ gstrBestand = Application.UserAppDataPath /// - Herfried K. Wagner [MVP] < http://www.mvps.org/dotnet> - 最诚挚的问候 - OHM O_H_M {at} BTInternet {dot} com Can someone point me the small error I have made here?Public Sub InitBestand()Dim Programma As ApplicationgstrBestand = Programma.UserAppDataPathIf Strings.Right(gstrBestand, 1) <> "\" Then gstrBestand &= "\"gstrBestand &= "beginner.txt"End SubThe error is:An unhandled exception of type ''System.NullReferenceException'' occurred insystem.windows.forms.dllAdditional information: Object reference not set to an instance of anobject.The line with the error is:gstrBestand = Programma.UserAppDataPathI thought it was enough to do "Dim Programma As Application"Apparently not?--localghost 解决方案--Best Regards - OHMO_H_M{at}BTInternet{dot}comSkip the 1st line and use this:\\\gstrBestand = Application.UserAppDataPath///--Herfried K. Wagner [MVP]<http://www.mvps.org/dotnet> -- Best Regards - OHM O_H_M{at}BTInternet{dot}com 这篇关于未设置对象引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-08 23:27