| CODE |
| cli::array<__wchar_t,1> ^charsplit = {'#'}; arglist->Split(charsplit, this->listBox1->Items->Count,System::StringSplitOptions::None);arglist2->Split(charsplit, this->listBox1->Items->Count,System::StringSplitOptions::None);/*(I also tried putting it in directly as the argument for my function and not ever putting it into an array variable, just using the text after the = sign... that didn't help*/ |
however after compiling and running my program that i'm working on, i get this error when the statement above is executed:
| QUOTE |
Unhandled exception has occurred in your application. If you click continue, the app will ignore this error and attempt to continue. if you click quit, the app will close immediately. Object reference not set to an instance of an object ************** Exception Text ************** System.NullReferenceException: Object reference not set to an instance of an object. at System.String.Split(Char[] separator, Int32 count, StringSplitOptions options) at System.String.Split(Char[] separator) at AutoRunCreator.createfile(String path, String label, String appex, String ico, Int32 argnumber, String args, String args2) form1.h:line 46 (Cut down after this, much much longer but all irrelavent) |
Help would be apreciated, and thanks -Leif902

Problems in System::String::Split... can't understand why this dosn't work...
Dave Comer
To go into more detail, here is the area the exception is comming from:
CODE
System::String ^arglist;
System::String ^arglist2;
//create arglist
this->listBox1->SelectedIndex = 0;
for (int i=0;i<(this->listBox1->Items->Count-1);i+=1)
{
arglist->Concat(this->listBox1->SelectedItem);
arglist->Concat("#");
//System::String::Concat(arglist,this->listBox1->SelectedItem);
//System::String::Concat(arglist,"#");
++this->listBox1->SelectedIndex;
}
//appen comlist to arglist2
this->cmdcomlist->SelectedIndex = 0;
for (int i=0;i<(this->cmdcomlist->Items->Count-1);i+=1)
{
arglist2->Concat(this->cmdcomlist->SelectedItem);
arglist2->Concat("#");
//System::String::Concat(arglist2,this->cmdcomlist->SelectedItem);
//System::String::Concat(arglist2,"#");
++this->cmdcomlist->SelectedIndex;
}
//break down args into argarrays
createfile(
this->choosesave->SelectedPath,
this->textBox1->Text,
this->textBox2->Text,
this->textBox3->Text,
(int)this->listBox1->Items->Count,
arglist->Split(gcnew array<wchar_t> { L'#'},this->listBox1->Items->Count,System::StringSplitOptions::None),
arglist2->Split(gcnew array<wchar_t> { L'#'},this->listBox1->Items->Count,System::StringSplitOptions::None));
}
Now, the above is the only code that really maters, i know this is a pretty stupid way of getting the arguments, but it does look cool, even if it does lead to bugs when they click on the list ;) -leif902
Alio
args2->Split(gcnew array<wchar_t> { L'#' });