|
-
Sep 1st, 2016, 07:13 AM
#1
Thread Starter
New Member
[RESOLVED] VS.NET 2015 getting System.NullReferenceExcept while trying to transfer Strings
-
Sep 1st, 2016, 07:54 AM
#2
Re: VS.NET 2015 getting System.NullReferenceExcept while trying to transfer Strings
You never create the 'truec' array. You declare the variable but you never create an array object and assign it to the variable.
-
Sep 1st, 2016, 10:50 AM
#3
Thread Starter
New Member
Re: VS.NET 2015 getting System.NullReferenceExcept while trying to transfer Strings
 Originally Posted by jmcilhinney
You never create the 'truec' array. You declare the variable but you never create an array object and assign it to the variable.
can you give me a code fix for this?
-
Sep 1st, 2016, 11:03 AM
#4
Thread Starter
New Member
Re: VS.NET 2015 getting System.NullReferenceExcept while trying to transfer Strings
If I declare 'truec' like
Dim truce(100) as string
there will be no problem and the program fun fine but if I remove the 100 from the truce I'll get the same error why, I want to make an array with out declare it's size like Dim splited() As String, and I use it.
-
Sep 1st, 2016, 12:23 PM
#5
Re: VS.NET 2015 getting System.NullReferenceExcept while trying to transfer Strings
You HAVE to give it a size at some point... or it doesn't exist. splitted() works because the Split function will resize the array and fill it. You need to do the same with truec array... you have to give it a size at some point, so the memory can be allocated and used.
I only see one index of truec being used - truec(0) ... is that the only index that's used? if that's the case, it doesn't need to be an array. If there are other indicies used... well... then yes, it needs to be an array.
-tg
-
Sep 1st, 2016, 01:35 PM
#6
Thread Starter
New Member
Re: VS.NET 2015 getting System.NullReferenceExcept while trying to transfer Strings
Thank you very much, I solve it after giving it a size.
Tags for this Thread
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
|