1、vb程序设计上机题目(VB programming topics)Forty-five1. basic operations (2 items, each item of 15 points, a total of 30 points)Note: the following “candidates folder“ are%USER%*Please according to the following questions of the design requirements of Visual Basic applications (including the interface and cod
2、e).(1) draw 1 image frames named Image1 on the form named Form1, which is titled “picture“The height is 2500 and the width is 2000. Please set the appropriate attribute through the attribute window and load it into the examinee directoryPicture file pic1.jpg, and make the picture adapt to the size o
3、f the image box (as shown).Be careful:Storage must be stored in the examinee folder, the project file named sjt1.vbp, the form file nameFor sjt1.frm.*(2) on the form named Form1, draw 1 text boxes named Text1, whose initial content is empty; and then the text box is emptyDraw 2 radio buttons, the na
4、mes are Option1, Option2, the titles are “participation“ and “no“Take the title of “Option1“ on the left of the radio button, as shown in the picture. When the program is running,Enter some text in Text1 (e.g., “match“) and click the Option1, then put the title on itEnter the front of the text (for
5、example, “participate in the contest“) and click the Option2, and then put the title on the lineEnter the back of the text (for example, “not participating in the competition“). Please write the appropriate event process to complete the aboveFunction.Be careful:When you save, save the file to the ex
6、aminee folder, the form file is called sjt2.frm, engineering documentThe piece is called sjt2.vbp. No variables are required in the program, and only one can be written in each eventSentence。analyse and comment onFirst a.:Create a form Form1, and set the Caption property of the form Form1 through th
7、e property window as “picture“. Click the Image control from the toolbox icon, then drag in the form of an image frame by Image1, the properties window set its Height property to 2500, the Width property is 2000, the Stretch property is True, and the Picture attribute add the candidates folder under
8、 the picture file pic1.jpg.Save the file as required and complete the question.Second a.:Create a new form Form1, click the TextBox control icon in the toolbox, and then drag out a text box Text1 on the form, through the window set its Text attribute is empty. Click the OptionButton control from the
9、 toolbox icon, then drag in the form of two radio buttons, Option1, Option2, the properties window set its Caption property is “in“, “out“, and the Alignment property of the Option1 radio button is set to 1-Right Justify.Open the code window and add the following codePrivate Sub Option1_Click ()Text
10、1.Text = Option1.Caption if Command2, call event Command2_Click, the process to label Label1 as the argument to the call the general process of ShowName, after the ShowName, in the form of the Label2 tag display “click the label control“.Open the code window, the modified code is as follows:Private
11、Sub Command1_Click ()Call ShowName (Command1)End SubPrivate Sub Label1_Click ()Call ShowName (Label1)End SubPrivate Sub ShowName (C As Control)If TypeOf C Is CommandButton ThenLabel2.Caption = “click“ and when the “object“ for the control of Left and Top respectively to control the left and top side
12、 and the left side of a form and the top edge of the relative distance.Problem solving method:The course of events for the Interval attribute Form_Load timer control set = 500; event Command1_Click to start the timer control Timer1; Command2_Click event process to stop the timer control Timer1; mobi
13、le Timer1_Timer is used to control the image of the course of events. Every time a timer event is executed, the picture moves from left to right 200, and the slider of the scrollbar moves along, that is to say, the picture and the scroll stick keep moving synchronously. The If statement to determine
14、 the right boundary, left boundary is completely out of form if it is greater than the form, left boundary width, namely If Picture1.LeftForm1.Width Then, the picture back to form the left edge of the picture, the left distance form the distance from the left border is 0.Open the code window, the mo
15、dified code is as follows:Private Sub Command2_Click ()Timer1.Enabled = FalseEnd SubPrivate Sub Form_Load ()Timer1.Interval = 500End SubPrivate Sub Timer1_Timer ()Picture1.Left = Picture1.Left + 200If Picture1.Left Form1.Width ThenPicture1.Left = 0End IfHScroll1.Value = Picture1.LeftEnd SubSave the
16、file as required to complete the question.3. comprehensive application (1 items, 30)Note: the following “candidates folder“ are%USER%Draw 1 text boxes on the form, called Text1 (display multiple lines), and then draw three command buttonsThe names of the buttons are Command1, Command2 and Command3,
17、respectively. The titles are “readings“ and “system“Save“ and “save“, as shown in the figure. The programs function is: click the “reading“ button, then the candidatesAll the English characters recorded in the in5.txt file are put into Text1 (multi line display)“Button“, find and count the English l
18、etters I, J, K, l, m, n (not case size) each outThe number of times; click the “save“ button, the letter I to n the number of occurrences of statistical results in turn to candidatesThe sequential file out5.txt in the directory.* attention:Storage must be stored in the examinee folder, the project f
19、ile named sjt5.vbp, the form file nameFor sjt5.frm.analyse and comment onThis paper mainly examines the operation of files and the processing of strings.1, Open statementThe Open statement is used to open or create a file:The name of the Open for access Access operating mode lock As # file number Le
20、n= record lengthParameter description:“Access mode“ refers to the input and output mode of the file, and can be one of the following operations:Output specifies the sequential output modeInput specifies the sequential input mode2, Input$function:Format: Input$(n, # document)The Input$function return
21、s a string of n characters read from the specified file. That is, it can read the specified number of characters from the data file.3, LOF functionThe LOF function returns the number of bytes allocated to the file (i.e. the length of the file).4, Print # statementUsed to write data to sequential fil
22、es. Grammar as:Print # document, Spc (n) |Tab (n) expression list; |. “The Spc (n) function is used to add n blanks at the current output position, and the Tab (n) function is used to write data in the n position.A semicolon indicates that the data that is subsequently written will be written at the
23、 end of the current data; the comma indicates a line break after the current data is written.5, Close statementUsed to close an open file. Grammar as:Close # file No.Open the code window, the “reading“, “Statistics“, “save“ button code is as follows:Option Base 1Dim a (6) As IntegerPrivate Sub Command1_Click ()Open App.Path Next IClose #1End SubSave the file as required to complete the question.