错误“对象引用未设置为对象的实例” [英] Error "Object reference not set to an instance of an object"
本文介绍了错误“对象引用未设置为对象的实例”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在我的代码中尝试这个时,我得到一个错误消息:对象引用
未设置为对象的实例
Dim g As System.Drawing.Graphics
g.DrawString(" Test",New Font(" Arial",12,FontStyle.Bold),Brushes.Black,
0,0)
为什么会这样?
Marc
When I try this in my code I alwas get an errormessage: "Object reference
not set to an instance of an object"
Dim g As System.Drawing.Graphics
g.DrawString("Test", New Font("Arial", 12, FontStyle.Bold), Brushes.Black,
0, 0)
Why is this?
Marc
推荐答案
Dim g as New System.Drawing.Graphics
" Microsoft" < Marc.VanSchandevijl@_nospam_.c-luma.com>在消息中写道
news:et ************** @ TK2MSFTNGP10.phx.gbl ...
Dim g as New System.Drawing.Graphics
"Microsoft" <Marc.VanSchandevijl@_nospam_.c-luma.com> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
当我尝试这个时我的代码我得到一个错误消息:对象引用
未设置为对象的实例
Dim g As System.Drawing.Graphics
g.DrawString(" ;测试",新字体(" Arial",12,FontStyle.Bold),Brushes.Black,
0,0)
为什么会这样?
> Marc
When I try this in my code I alwas get an errormessage: "Object reference
not set to an instance of an object"
Dim g As System.Drawing.Graphics
g.DrawString("Test", New Font("Arial", 12, FontStyle.Bold), Brushes.Black,
0, 0)
Why is this?
Marc
嗯..
尽量不要将它声明为实例..抱歉,我之前没有指出
...
只需直接调用System.Drawing.Grapichics.DrawString
或导入System.Drawing.Graphics并调用DrawString。
" Microsoft" < Marc.VanSchandevijl@_nospam_.c-luma.com>在消息中写道
news:et ************** @ TK2MSFTNGP10.phx.gbl ...
Um..
Try to not declare it as an instance... sorry I didn''t point that out
earlier...
Just directly call System.Drawing.Grapichics.DrawString
or import System.Drawing.Graphics and just call DrawString.
"Microsoft" <Marc.VanSchandevijl@_nospam_.c-luma.com> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
当我尝试这个时我的代码我得到一个错误消息:对象引用
未设置为对象的实例
Dim g As System.Drawing.Graphics
g.DrawString(" ;测试",新字体(" Arial",12,FontStyle.Bold),Brushes.Black,
0,0)
为什么会这样?
> Marc
When I try this in my code I alwas get an errormessage: "Object reference
not set to an instance of an object"
Dim g As System.Drawing.Graphics
g.DrawString("Test", New Font("Arial", 12, FontStyle.Bold), Brushes.Black,
0, 0)
Why is this?
Marc
另一个错误我害怕(有两个解决方案):
对非共享成员的引用需要对象引用。
Marc
CJ Taylor <克拉***** @ mortonwelding.com> schreef in bericht
新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...
Another error I''m afraid (with both solutions):
"Reference to a non-shared member requires an object reference."
Marc
"CJ Taylor" <ct*****@mortonwelding.com> schreef in bericht
news:%2****************@TK2MSFTNGP10.phx.gbl...
嗯。 。
尽量不要将它声明为实例...对不起我之前没有指出
只需直接调用System即可。 Drawing.Grapichics.DrawString
或导入System.Drawing.Graphics并调用DrawString。
" Microsoft" < Marc.VanSchandevijl@_nospam_.c-luma.com>在消息中写道
新闻:et ************** @ TK2MSFTNGP10.phx.gbl ...
Um..
Try to not declare it as an instance... sorry I didn''t point that out
earlier...
Just directly call System.Drawing.Grapichics.DrawString
or import System.Drawing.Graphics and just call DrawString.
"Microsoft" <Marc.VanSchandevijl@_nospam_.c-luma.com> wrote in message
news:et**************@TK2MSFTNGP10.phx.gbl...
当我在我的代码中尝试这个时,我也是获取错误消息:对象
引用未设置为对象的实例
Dim g As System.Drawing.Graphics
g.DrawString(" Test",新字体(Arial,12,FontStyle.Bold),
Brushes.Black,0,0)
为什么会这样?
Marc
When I try this in my code I alwas get an errormessage: "Object reference not set to an instance of an object"
Dim g As System.Drawing.Graphics
g.DrawString("Test", New Font("Arial", 12, FontStyle.Bold), Brushes.Black, 0, 0)
Why is this?
Marc
这篇关于错误“对象引用未设置为对象的实例”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文