未设置对象引用 [英] Object reference not set

查看:59
本文介绍了未设置对象引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能指出我在这里犯的小错误吗?

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

解决方案

Dim Programma作为新应用


问候 - OHM


localhost写道:

有人能指出我在这里犯的小错误吗?

Public Sub InitBestand()
Dim Programma As Application
gstrBestand = Program ma.UserAppDataPath
如果Strings.Right(gstrBestand,1)<> " \"然后gstrBestand& =
" \" gstrBestand& =" beginner.txt"
End Sub

错误是:
发生了'System.NullReferenceException''类型未处理的异常system.windows.forms.dll

附加信息:对象引用未设置为
对象的实例。

带错误的行是:
gstrBestand = Programma.UserAppDataPath

我认为Dim Programma As Application就足够了
显然不是吗?




-

最诚挚的问候 - OHM


O_H_M {at} BTInternet {dot} com


< blockquote> * localhost< lo ******* @ localdomain.org> scripsit:

有人能指出我在这里犯的小错误吗?

Public Sub InitBestand()
Dim Programma As Application
gstrBestand = Programma .UserAppDataPath
如果Strings.Right(gstrBestand,1)<> " \"然后gstrBestand& =" \"
gstrBestand& =" beginner.txt"
End Sub




跳过第1并且使用它:


\\\

gstrBestand = Application.UserAppDataPath

///


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>


???


我正在研究这个,''我的第一次尝试,但是构造函数

应用程序是私人的。

十六进制。


单手男[OHM#]" < O_H_M {在} BTInternet {点} COM>在留言中写道

news:%2 **************** @ TK2MSFTNGP09.phx.gbl ...

Dim Programma作为新应用

问候 - OHM

localhost写道:

有人能指出我在这里犯的小错误吗?

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作为应用程序就足够了
显然不是吗?



-
最诚挚的问候 - 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 Application
gstrBestand = Programma.UserAppDataPath
If Strings.Right(gstrBestand, 1) <> "\" Then gstrBestand &= "\"
gstrBestand &= "beginner.txt"
End Sub
The error is:
An unhandled exception of type ''System.NullReferenceException'' occurred in
system.windows.forms.dll

Additional information: Object reference not set to an instance of an
object.

The line with the error is:
gstrBestand = Programma.UserAppDataPath

I thought it was enough to do "Dim Programma As Application"
Apparently not?

--
localghost

解决方案

Dim Programma As New Application

Regards - OHM

localhost wrote:

Can someone point me the small error I have made here?
Public Sub InitBestand()
Dim Programma As Application
gstrBestand = Programma.UserAppDataPath
If Strings.Right(gstrBestand, 1) <> "\" Then gstrBestand &=
"\" gstrBestand &= "beginner.txt"
End Sub
The error is:
An unhandled exception of type ''System.NullReferenceException''
occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an
object.

The line with the error is:
gstrBestand = Programma.UserAppDataPath

I thought it was enough to do "Dim Programma As Application"
Apparently not?



--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com


* localhost <lo*******@localdomain.org> scripsit:

Can someone point me the small error I have made here?

Public Sub InitBestand()
Dim Programma As Application
gstrBestand = Programma.UserAppDataPath
If Strings.Right(gstrBestand, 1) <> "\" Then gstrBestand &= "\"
gstrBestand &= "beginner.txt"
End Sub



Skip the 1st line and use this:

\\\
gstrBestand = Application.UserAppDataPath
///

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>


???

I''m just working on this one, ''twas my first try too but the constructor for
"Application" is private.
Hex.

"One Handed Man [ OHM# ]" <O_H_M{at}BTInternet{dot}com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...

Dim Programma As New Application

Regards - OHM

localhost wrote:

Can someone point me the small error I have made here?
Public Sub InitBestand()
Dim Programma As Application
gstrBestand = Programma.UserAppDataPath
If Strings.Right(gstrBestand, 1) <> "\" Then gstrBestand &=
"\" gstrBestand &= "beginner.txt"
End Sub
The error is:
An unhandled exception of type ''System.NullReferenceException''
occurred in system.windows.forms.dll

Additional information: Object reference not set to an instance of an
object.

The line with the error is:
gstrBestand = Programma.UserAppDataPath

I thought it was enough to do "Dim Programma As Application"
Apparently not?



--
Best Regards - OHM

O_H_M{at}BTInternet{dot}com



这篇关于未设置对象引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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