string sLastCode = null; string sNextCode = ""; while( sNextCode != "Z9999" ) { sNextCode = GetNextCode(sLastCode); // fait quelquechose avec sNextCode ici sLastCode = sNextCode; }
public static string GetNextCode(string sLastCode) { // Fait attention aux bornes inf et supp if ( String.IsNullOrEmpty(sLastCode) || sLastCode == "Z9999" ) return "A0001"; // Suivant string sNextCode = string.Empty; if ( Convert.ToInt32(sLastCode.Substring(1,4)) == 9999 ) sNextCode = (((char)((int)sLastCode[0])=='Z') ? 'A' : (char)((int)sLastCode[0]+1)) + "0001"; else sNextCode = (char)((int)sLastCode[0]) + (Convert.ToInt32(sLastCode.Substring(1,4))+1).ToString("0000"); return sNextCode; }
string sLastCode = "E9999"; string sNextCode = GetNextCode(sLastCode);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question