//straat controle voor opsplitsing string naar straat + nr + bus private Boolean straatControleren(Leerling leerling) { string[] str = leerling.straat.Split(' '); //voor een adres bestaande uit straat (in 1 woord) + nr if (str.Length == 2) { leerling.straatZonderNr = str[0]; leerling.huisNr = str[1]; return(true); } if (str.Length == 3 && (System.Text.RegularExpressions.Regex.IsMatch(str[2], @"^\d+$"))) { leerling.straatZonderNr = str[0] + " " + str[1]; leerling.huisNr = str[2]; return(true); } straatControle = new StraatControleScherm(leerling); var testAdres = straatControle.ShowDialog(); if (testAdres == DialogResult.OK) { return(true); } else { return(false); } }
//straat terug geven na splitsen straat string public void straatControleren(Leerling leerling) { string[] s = straat.Split(Convert.ToChar(" ")); //voor straatnaam uit 1 stuk zonder bus of andere extraas if (s.Length == 2) { leerling.straatZonderNr = s[0]; leerling.huisNr = s[1]; } else { if (s.Length == 3 | Regex.IsMatch(s[s.Length - 1], @"^\d")) { straatZonderNr = s[0] + s[1]; huisNr = s[s.Length - 1]; } else { //scherm aanmaken om gebruiker manueel het adres te laten controleren StraatControleScherm controleScherm = new StraatControleScherm(leerling); } } }