473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

VB.NET: Object reference not set to an instance of an object

36
I'm receiving an object reference not set to an instance of an object on the
( RevLen = ReverseText.Length) line of code. Can anyone help with this problem?

Thanks,
William Boswell

For Each item As Integer In PositionArray

Dim RevLen As Integer

RevLen = ReverseText.Length

Dim j As Integer

Dim char2 As Char

For j = 0 To RevLen - 1

char2 = ReverseText.Chars(j)

If item = j Then

Char.ToUpper(char2)

End If

CapRevText += char2 + " "

Next
Nov 5 '07 #1
4 1396
Plater
7,872 Expert 4TB
Where do you specify what ReverseText is?
Expand|Select|Wrap|Line Numbers
  1. For Each item As Integer In PositionArray
  2.    Dim RevLen As Integer
  3.    RevLen = ReverseText.Length
  4.    Dim j As Integer
  5.    Dim char2 As Char
  6.    For j = 0 To RevLen - 1
  7.       char2 = ReverseText.Chars(j)
  8.    If item = j Then
  9.       Char.ToUpper(char2)
  10.    End If
  11.    CapRevText += char2 + " "
  12. Next
  13.  
And shouldn't this:
For j = 0 To RevLen - 1

Really be this:
For j = 0 To RevLen.Length - 1
Nov 5 '07 #2
wbosw
36
ReverseText is scoped at the class level. The integer variable RevLen is holding ReverseText.Length.


Where do you specify what ReverseText is?

Code: ( vbnet )
For Each item As Integer In PositionArray
Dim RevLen As Integer
RevLen = ReverseText.Length
Dim j As Integer
Dim char2 As Char
For j = 0 To RevLen - 1
char2 = ReverseText.Chars(j)
If item = j Then
Char.ToUpper(char2)
End If
CapRevText += char2 + " "
Next


And shouldn't this:
For j = 0 To RevLen - 1

Really be this:
For j = 0 To RevLen.Length - 1
Nov 5 '07 #3
Plater
7,872 Expert 4TB
oops, that will teach me not to look closer (was thinking RevLen was your string)


If you have:
Dim RevLen As Integer
RevLen = ReverseText.Length

and the second line is giving you an object reference not set to an instance, that would imply that ReverseText is null (Nothing for you VBers).
Throw in a Not is Nothing (or whatever it is in VB) check beforehand?
Nov 5 '07 #4
wbosw
36
Thanks Plater, I looked a little closer myself and found why it was receiving the Null reference.

Thanks again,
Wbosw
Nov 6 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Franco Gustavo | last post by:
Hi, All What's is the best .net profiler for Debug an application. I have to buy one but I don't know which one!! I tried some of them like Borland and AQTime. My big problem is, my...
10
by: Brad | last post by:
Question for all: Would one consider this a loophole in .net with respect to nested (inner) classes? 1) Create outer class Foo and create a nested class Yin (inside Foo's class definition...
5
by: Saga | last post by:
Hi all, I just read the thread by the same name posted on Jun 15, 9:45 AM, but I am looking at it from a different point of view. I came across this question in terms of functionality. Are VB and...
8
by: Angel | last post by:
Hi everybody, I am new to ASP.NET, and my question might be obvious to most of you but I do not seem to find many things about threads and ASP.NET. I have an object(Object 1) which need some...
13
by: John Rivers | last post by:
Here is an example of what I am talking about: asp.net takes what is a very simple, powerful and flexible concept, http request/response with html for presentation and turns it into a...
7
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
7
by: John A Grandy | last post by:
For a singleton class utilizes by ASP.NET 2.0 page processing: When initial instantiation is performed during the initial call to the retrieve instance method (let's call the method...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.