'System.NullReferenceException

S

Supra

An unhandled exception of type 'System.NullReferenceException' occurred
in irc_client.exe
Additional information: Object reference not set to an instance of an
object.

'UPGRADE_WARNING: Arrays can't be declared with New. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1045"'
Public ChannelArray() As frmChannel

Dim intArrayCount As Short
intArrayCount= ChannelArray.GetUpperBound(0) <== error occured in this
in yellow highlightened

regards,
 
C

Carlos J. Quintero [.NET MVP]

That happens because the ChannelArray variable has not been assigned and it
is Nothing.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
S

Supra

can i add new keyword in variable?
Public ChannelArray() As new frmChannel < i added new keyword... does
this help?
regards
 
C

Carlos J. Quintero [.NET MVP]

No, arrays can not use the New keyword.

If the size of the array is known, you can initialize the array as follows:

Public ChannelArray(10) As frmChannel

Otherwise, you could use an ArrayList class instead, for example:

Public ChannelArray As New ArrayList()

and then use the ChannelArray.Add(...) method.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Supra" <[email protected]> escribió en el mensaje can i add new keyword in variable?
Public ChannelArray() As new frmChannel < i added new keyword... does this help?
regards
 
H

Herfried K. Wagner [MVP]

Supra said:
An unhandled exception of type 'System.NullReferenceException' occurred
in irc_client.exe
Additional information: Object reference not set to an instance of an
object.

'UPGRADE_WARNING: Arrays can't be declared with New. Click for more:
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1045"'
Public ChannelArray() As frmChannel

=> 'Public ChannelArray(-1) As frmChannel'
 
H

Herfried K. Wagner [MVP]

Supra said:
can i add new keyword in variable?
Public ChannelArray() As new frmChannel < i added new keyword... does

\\\
Public ChannelArray() As frmChannel = New frmChannel() {}
///
 
S

Supra

that what i was going to asked u about arrylist
i will try both...if not..... :-(
regards
 
C

Cor Ligthert

Supra,

Can you explain what you want to achieve, because clearing the error will
not be a problem, however in my idea don't you than have with that the
sollution you want.

Cor
 
C

Carlos J. Quintero [.NET MVP]

Apart from the array statements that exist in each language, the .NET Framework provides you also classes that are arrays, collections, dictionaries, queues, stacks, etc. They provide specialized behaviors that are needed sometimes. Take a look at the docs.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

"Supra" <[email protected]> escribió en el mensaje that what i was going to asked u about arrylist
i will try both...if not..... :-(
regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top