Do not think that the student information management system is difficult!

Source: Internet
Author: User

Ah, okay. Today I am still bringing you a large gossip computer continuous program VB tuting class. We are still spitting out, and it feels so disgusting...

Since I posted a blog post on csdn last time, I have been living in the hot life of previewing professional courses. After all, you can't rely on others to take exams, right? You should do well in the small copy, of course, we still need to implement the "Be brave, give a look, and give a glance" principle. Speaking of this exam, I had to vomit: it was too difficult to learn in class!

It's also summer vacation. At last, the school had nothing to do and we had to learn it without delay. I almost forgot my csdn password for the past two months... Recently, I finally barely caught up with the big army. Somehow, I finished the student information management system. According to international practice, we should make a summary after completing the work, so


Do not think that the student information management system is difficult!


When I first got the source code, I was so tired that there were as many forms as wool. Director Mi, did I go to the wrong scene? Hello!

Let's take a closer look. The first menu is add, modify, and exit. The second menu is add, modify, and query. The third menu is add, modify, and query...

Ah, it turns out to be similar.

In fact, after getting it, I carefully looked at every form, which is about the same code. The difference is that some places use different methods to achieve the same effect.

I think the most difficult part is this module. Well, in order to explain the code carefully, I opened it and wrote it. (You just want to add a few more blogs -_-)

Sub main () dim flogin as new frmlogin flogin. show vbmodal: the logon window is displayed, so that you can only use the current form. Other forms can be used only when the current form is closed. If not flogin. OK then' if OK in the flogin form is not true, the end program end if unload flogin set fmainform = new frmmain 'displays the main form fmainform. showend sub

First, I wrote this sub main () in the comment to only display the logon form. Well, in fact, I want to directly set the startup object as a logon form, that is, frmlogin. I just need to add some code in it, so I will not write anything...

Public Function testtxt (txt as string) as Boolean 'judge whether text is null if trim (txt) = "" Then testtxt = false else testtxt = true end ifend Function

Then this is the thing, which is also written in the comment. This function is only used to check whether the textbox is empty. In fact, you can directly use TRIM (txt) to determine whether it is null, define a function for convenience.

Public Function connectstring () as string 'method 1 connectstring = "filedsn = student. DSN; uid = sa; Pwd = 123456; server = 192.168.1.1; persist Security info = false "'method 2 'connectstring =" provider = sqloledb; uid = sa; Pwd = 123456; initial catalog = student; Data Source = 192.168.1.1 "End Function

Next we will talk about the database connection function. We also talked about two Connection Methods in the last tuao class. The server that links to the SQL server in the LAN only adds an IP address in its own code. Of course, you must first enable the remote connection service on the server.

Public Function executesql (byval SQL as string, msgstring as string) as ADODB. recordset 'executes the SQL statement and returns a result set 'executes SQL and returns recordset dim CNN as ADODB. connection dim rst as ADODB. recordset dim metrics ens () as string 'defines a string array on error goto executesql_error metrics ens = Split (SQL)'. The SQL string is divided into string arrays by spaces, set CNN = new ADODB. connection CNN. open connectstring if instr ("inssert, delete, update", ucase $ (stoken S (0) then' if the first word is in uppercase, such as inssert, delete, and update. That is, non-select statement CNN. Execute SQL 'Execute the SQL statement msgstring = ens (0) & "query successful" else' SELECT statement set rst = new ADODB. recordset rst. open trim $ (SQL), CNN, adopenkeyset, adlockoptimistic set executesql = rst msgstring = "found" & rst. recordcount & "record" end if executesql_exit: Set rst = nothing set CNN = nothing exit function executesql_error: msgstring = "query error:" & err. description resume executesql_exit end Function

The most difficult part is this function. Let me have a chat and continue...

I don't know where to start at that time. Let's briefly describe the functions of this function. First, the SQL statements in the accepted text format are grouped by space according to the comments, and then the data in the first array is judged. If the SQL statement is not a SELECT statement, it is executed directly, if it is a SELECT statement, a result set is returned. In fact, I wrote a comment clearly enough. Why?

Wow, I can write so much about a module! I won't say that I have completely stuck the code...

For the remaining forms, I will continue in the next phase ~

Above

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.