Student Information Management System titbits

Source: Internet
Author: User
Tags goto

Student Information Management System titbits

The 1.Option Explicit statement is used at the module level to force an explicit declaration of all variables in the module. Option EXPLICIT statement must be written before all procedures in the module. If you use Option Explicit in a module, you must explicitly declare all variables using Dim, Private, public, ReDim, or Static statements. If you use a variable name that is not declared, an error occurs at compile time. If you do not use the Option Explicit statement, all undeclared variables are variant unless you specify the default type by using the Deftype statement. Note: Using optionexplicit to avoid typos when you type an existing variable, you can avoid confusion by using it in code where the scope of the variable is not very clear.

2.MDIForm i.e. ' MDI (multiple Document interface)

(1) All subforms are displayed in the working space of the MDI form.

(2) When a subform is minimized, its icon appears on the MDI form instead of the taskbar.

(3) When you maximize a subform, its caption is grouped with the title of the MDI form and displayed on the MDI title bar.

(4) By setting the AutoShowChildren property, the subform can be automatically displayed or hidden automatically when the form is loaded.

(5) The menu (if any) of the active subform appears in the menu bar of the MDI form, not in the subform.

3.me.left = GetSetting (App.title, "settting", "Mainleft", 1000)

The GetSetting function returns the registry key setting value from the Application project in the Windows registry.

Grammar:

GetSetting (appname,section, key[, default))

The syntax for the GetSetting function has the following named arguments:

Part Description:

AppName necessary. A string expression that contains the name of an application or project that requires a registry key setting for those applications or projects.

Section necessary. A string expression that contains the name of a zone that requires a registry key setting in the zone.

Key necessary. A string expression that returns the name of the registry key setting.

Default is optional. expression that returns the default value if no value is set in the registry key setting. If omitted, the default takes a zero-length string ("").

Description

If none of the parameters in the GetSetting exists, GetSetting returns the value of default.

4..SaveSetting statement to save or establish an application project in the Windows registry


5..On Error GoTo 0

Represents the prohibition of any initiated error handlers in the current procedure.

On Error Resume Next

Explains that when a run-time error occurs, the control goes to the statement immediately following the statement where the error occurred, and continues to run here. Use this form instead of on Error GoTo when accessing an object.

On Error GoTo Line

Starts the error handler, and the routine starts with the line specified in the necessary line arguments. The line argument can be any row label or line number. If a run-time error occurs, the control jumps to line and activates the error handler. The specified line must be in a procedure that is the same as the On Error statement, otherwise a compile time error occurs.

On Error GoTo next that is ignoring the error and going down.

6.getusername This function is a case-sensitive word, it should be written as GetUserNameA

7.ADODB is a Dynamic Data link object

A recordset is a subclass of ADODB

In general, we define:

Dim Rst as New ADODB. Recordset

You can use the RST directly later.

8. Find out if a new added record is duplicated with an existing record

Look for existing records from the database to be stored in a recordset, when the Recordset is Non-empty, from the first record to determine whether to repeat, if repeated exit sub, if not repeat, continue to judge the next one.

        txtSQL = "select* from User_info"
  
        Set MRC = ExecuteSQL (Txtsql,msgtext) while
  
        (MRC). EOF = False)
  
         If trim$ (MRC. Fields ("user_name"). Value) =trim$ (txtusername.text) Then
  
                   MsgBox "User already exists, please re-enter user name!", vbOKOnly + vbexclamation, "warning"
  
                   Txtusername.setfocus
  
                   txtUsername.Text = ""
  
                   txtpassword1.text = ""
  
                   txtpassword2.text = ""
  
                   Exit Sub
  
        Else
  
                   MRC. MoveNext
  
        EndIf
  
        wend

Mrc. EOF = False indicates that the MRC Recordset is not empty and often uses MRC. The values of BOF and EOF determine whether the recordset is empty.

9.ExecuteSQL (txtSQL, Msgtext) is a custom function

ExecuteSQL must be executing an SQL statement (in English meaning this-usually defined by the use of the name)

The two parameters in the txtSQL refer to the SQL statement used for execution, such as the SELECT * from table

The Msgtext parameter refers to whether the pop-up box after the Execute SQL statement succeeds or fails.

10.CellAlignment

Set the text in the table to its way, there are text relative to the table and text and text alignment, the way it is cellalignment to set the value to determine, generally we will choose, the text pass-type are centered, so that more good-looking, beautiful some.

In the use of Textmatrix (I,J), you should pay attention to the range of i,j, it is very easy to subscript out of bounds, and so on, and then we use the Textmatrix (I,j) property, the number of rows can not be zero, otherwise there is a subscript out of bounds.

Textmattix rows and I in Textmatrix (I,J) are generally 1, so we often use some textmatrix in our code. ROWS-1,J), probably because of this, in the VB array or set subscript or index is usually starting from 0, this we should pay attention to use, so as to avoid errors.

IsNumeric function in 12.VB

Returns a Boolean value that indicates whether the expression evaluates to a number.

Grammar isnumeric (expression)

The necessary expression parameter is a Variant that contains a numeric expression or a string expression.

Indicates that IsNumeric returns True if the entire expression operation results in a number, otherwise it returns FALSE. If expression is a date expression, IsNumeric returns False.

13.DD (4)

Dim indicates that the variable is declared in VB, the variable named DD, and (4) represents the variable from 0 to 4 of five, Boolean representing the Boolean variable (only true (true) and False (false) two values)

Examples of specific variable assignments are as follows:

DD (0) = True ' sets DD's No. 0 variable to True

DD (1) = False ' sets DD's 1th variable to False

' And so on ...

14.

Public
 Sub ViewData () ' Assignment procedure  
         txtstuid.text = studentinfo.fields (0)  
         Txtstuname.text = Studentinfo.fields (1)  
         Cmbsex.text = Trim (Studentinfo.fields (2))  
         Dtpbirthday.value = Format ( Studentinfo.fields (3), "Yyyy-mm-dd")  
         Cmbclassno.text = Studentinfo.fields (4)  
         Txttel.text = Studentinfo.fields (5)  
         dtpentrancedate.value = Format (Studentinfo.fields (6), "Yyyy-mm-dd")  
         Txtaddress.text = Studentinfo.fields (7)  
         Txtcomment.text = Studentinfo.fields (8) End    
 sub</span>  
 


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.