Functional Block of the student information management system

Source: Internet
Author: User

When I knocked on the student information management system to modify the class information form today, when I knocked on the code for deleting the record, I suddenly understood the concept of "function block" very deeply.

The following code is used to explain the problem:

If str2 $ = vbokthen

MRC. movenext: Find the next entry to be displayed after deletion.

If MRC. EOF then

MRC. movefirst

Mybookmark = MRC. bookmark

MRC. movelast '??

If MRC. recordcount = 1 then

MRC. Delete

Unload me

Exit sub

Else

MRC. Delete

MRC. Bookmark = mybookmark

Call viewdata 'display deleted records

End if

Else

Mybookmark = MRC. bookmark

MRC. moveprevious 'record set pointer, pointing to the record to be deleted

MRC. Bookmark = mybookmark' record set pointer pointing to the next deleted

Call viewdata: The next deleted record is displayed.

End if

Else

MRC. Bookmark = mybookmarkf

Call viewdata

End if

This is the code for deleting records. What does this code mean?

'Bookmark indicates the location of the current DBGrid. The function here is to record the location of the current DBGrid when the point is deleted,

'If you are sure you want to delete the file, check whether it is the last one,

'If yes, return to the first line, delete, and leave the location in the first line,

'If it is not the last one, the data will be deleted and the bookmark will be in the current position;

'If the deletion is not performed, the bookmark remains unchanged at the current position.

So we can certainly understand it, but how can we understand the code ?? Now let's take a look.

This code has three more if statements, that is, three functional blocks.

First, let's look at one of the most:

If MRC. recordcount = 1 then' this code records only one special case
MRC. Delete
Unload me
Exit sub
End if

Let's look at the second one:

If MRC. EOF then 'delete record at the last position

MRC. movefirst

Mybookmark = MRC. bookmark

MRC. movellast

MRC. Delete

MRC. Bookmark = mybookmark

Call viewdata

Else' the deleted record is not in the last one

Mybookmark = MRC. bookmark

MRC. moveprevious

MRC. Delete

MRC. Bookmark = mybookmark

Call viewdata

End if

It is much easier to look at the peripheral situations.

If str2 $ = vbokthen

MRC. movenext

.......

Else

MRC. Bookmark = mybookmarkf

Call viewdata

End if

I think the main function of the function block is ① To connect the code of this function after reading or writing it at one time, which is very helpful for understanding and will not look at the code of this function for a while, later I will look at the code section of that function, leading to confusion in the Code understanding.

② When writing code, no sentence will be lost.

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.