The question is proposed: In modern society, a person always inseparablely. People always have an ID number in the society, and students will have a student number in school, and these numbers are not all meaningless numbers. The program I wrote is used to analyze these numbers and express it in meaningful meaning. Programming Environment: VS.NET Implementation Technology: ASP.NET Key: String.Substring (INT32, INT32) method Application, Literal control usage, Switch statement is used. Text: On the web form, put a Label control, a Literal control, a TextBox control, a Button control. Set the text attribute of the Label control to "your students:", the Visible property of the Literal control is set to "False". I mainly encode the Click () event of the Button control. When the button is clicked, the input number is analyzed, and then the content of the analysis is displayed with the Literal control.
Button control Click () event: string studentno = txtno.text; // assigns a student number to the StudentNo string if (! Studentinfo.visible) {studentinfo.visible = true; // If the Litral control is invisible, then Show it.} Try {// Subconstruction String string string strsTartyear = studentno.substring (0, 2); // Entry Year String strading "= studentno.substring (2, 1); // String string string strandool = studentno.substring 3, 2); // College string strclass = studentno.substring (5, 1); // class string strnumber = studentno.substring (6, 2); // Number // Corresponding to the text // content pure The fictional Switch (strschool) {case "01": strschool = "literary school"; Break; Case "02": strschool = "Science"; BREAK; CASE "03": STRSCHOOL = "Engineering"; Break; Case "04": strschool = "Science and Technology"; Break; Case "05": strschool = "Spread and Art"; Break; Case "06": strschool = "Business School" Break; Case "07": strschool = "Law School"; Break; Case "08": strschool = "Vocational Education College";
Break; Case "09": strschool = "Construction Institute"; Break; Case "10": strschool = "Information"; Break; default: strschool = "子 虚 乌"; Break;} studentinfo.text = "You" strStartyear "Admission" ", the selected major is" "" "" You now " " "in the" strschool "class" ", your number is:" Strnumber ".";} Catch {response.write ("Subsidence operation and crosses!");} Finally {} Note: The students here are 8 bits. Example: After the web application is run, enter: 02408122 in the text box: 02408122. Look at what the result is? :) Rendering: Extension of the program: In order to prohibit the content of the incorrect, you can add a regularExpressionValidator and a validationsummary control, the regular expression is "/ d {8}", when the input is not 8 digits, will be on the page The error message is displayed. Abstract: The analysis of the ID card number is similar to the analysis of the students. Text: I think the ID number is 18. Add a Label control on the page, a TextBox control, a Button control, a Litral control. The Text property of the Label control is set to "Issue:", the Literal control will display the information in the ID number. The key is still in the Click () event of the Button control.
Button control Click () event: string strid = txtid.text; if (! Txtid.visible) {txtid.visible = true;} try {string stryear = strid.substring (6,4); // year string strmonth = Strid.substring (10, 2); // month string strday = Strid.Substring (12, 2); // day literal1.text = "Your birthday is:" strinoear "year" strMonth "Month" strDay "号";} catch {response.write ("program has an error!");} Finally {} display renderings: transferred from: http://blogview.asp? LogID = 1154