array<String^> ^NewUsernames = NewUsernames = gcnew array<String^>(0);

	String ^sPastedString;
	String ^sName;
	String ^sMarker = "[MARKERdfghj23l]";
	int Count;

	try
	{
		
		sPastedString = txtPasteUsernames->Text;
		txtPasteUsernames->Text = "";
		sPastedString = sPastedString->Trim();

		if (sPastedString->Length <= 1)		//Ignore single character in case user tries to type into box
			return;

		//Place markers between each name
		sPastedString = sPastedString->Replace("\r\n", sMarker);
		sPastedString = sPastedString->Replace("\n", sMarker);
		sPastedString = sPastedString->Replace("\r", sMarker);
		sPastedString = sPastedString->Replace(",", sMarker);
		sPastedString = sPastedString->Replace("\t", sMarker);
		sPastedString += "[MARKERdfghj23l]";

		//Get each name
		while (sPastedString->LastIndexOf(sMarker) > 0)
		{
			sName = sPastedString->Substring(0, (sPastedString->IndexOf(sMarker)));
			sPastedString = sPastedString->Substring(sName->Length + sMarker->Length);

			sName = sName->Trim();
			if (sName->Length > 0)
			{
				//Check name has not already been added
				for (Count = 0; Count < NewUsernames->Length; Count++)
				{
					if (NewUsernames[Count] == sName)
						break;
				}
				if (Count == NewUsernames->Length)
				{
					//Add it to the array
					Array::Resize(NewUsernames, NewUsernames->Length + 1);
					NewUsernames[(NewUsernames->Length - 1)] = sName;
				}
			}
		}

		//----- DISPLAY THE ARRAY OF USERNAMES -----
		txtUsernamesToAdd->Text = "";
		for (Count = 0; Count < NewUsernames->Length; Count++)
		{
			txtUsernamesToAdd->Text += NewUsernames[Count] + "\r\n";
		}
	}
	catch (Exception ^e)
	{
		GlobalObjects::EventLog1->AddEvent(true, 0x00, Convert::ToString(e));
	}

 

 

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *