|
-
Apr 24th, 2004, 06:50 PM
#1
Thread Starter
New Member
Object reference not set to an instance of an object.
I am trying to write a .dll to use to pull up a text so I can count each character, word, paragraph, & sentence. When I trie dto use streamreader to open file I get this:
System.NullReferenceException: Object reference not set to an instance of an object
Here is the code that is getting error
Dim stringProcessor As Course.Class1
ofdMain.ShowDialog()
stringProcessor.StringContents = txtRead.[Text]
txtCharacters.[Text] = Microsoft.VisualBasic.CompilerServices.StringType.FromInteger(stringProcessor.Characters)
txtWords.[Text] = Microsoft.VisualBasic.CompilerServices.StringType.FromInteger(stringProcessor.Words)
txtSentences.[Text] = Microsoft.VisualBasic.CompilerServices.StringType.FromInteger(stringProcessor.Sentences)
txtParagraphs.[Text] = Microsoft.VisualBasic.CompilerServices.StringType.FromInteger(stringProcessor.Paragraphs)
Return
Any help w/ this would be appreciated
-
Apr 24th, 2004, 07:23 PM
#2
Frenzied Member
This error generally means that you forgot to instantiate a new instance of the object.
Which means that you forgot to use the "New" keyword.
The code below will throw an error, because although myTextBox has been declared, it hasn't been instantiated as a new TextBox object.
VB Code:
Dim myTextBox As TextBox
myTextBox.Text = "Blah"
This code will work
VB Code:
Dim myTextBox As TextBox
myTextBox = New TextBox
or
Dim myTextBox As New TextBox
myTextBox.Text = "Blah"
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|