The first computer room computer system -- Summary

The time is fleeting. In a twinkling of an eye, the first computer room system has been completed. Although it has been a month and a half, there is also its own procrastination disorder, but it is finally over. After this period of study, I summarize the following points:

1. The code format should be correct and clear, otherwise BUG will increase a lot.
2. Fill in the necessary comments, otherwise when debugging the code, you will not know what you are writing.
3. The name of a variable, otherwise you don't know what a variable stands for until the end.
4. If there is a BUG, the variable type of the data should also be recorded.
5. If you have your own ideas, add them in. If you have more problems, you will grow naturally.
6. If you don't solve the problem in two hours, you need the help of your friend!

code

You can input alphanumeric characters and Chinese characters

Public Function Limit(KeyAscii%) As Integer
    Select Case KeyAscii
        Case Is < 0
        Case 13 'Enter
        Case 8 'delete
        Case 32 'Space
        Case Asc("a") To Asc("z")
        Case Asc("A") To Asc("Z")
        Case Asc("0") To Asc("9")
    Case Else
        KeyAscii = 0
    End Select
    
End Function

You can input letters and Chinese characters

'Limit the ability to input letters and Chinese characters
Public Function GradeLimi(KeyAscii%) As Integer
    Select Case KeyAscii
        Case Is < 0
        Case 13 'Enter
        Case 8 'delete
        Case 32 'Space
        Case Asc("a") To Asc("z")
        Case Asc("A") To Asc("Z")
    Case Else
        KeyAscii = 0
    End Select

End Function

Get computer name

'statement
Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

'call API Function to get the computer name
 
Public Function GetThisComputerName() As String
    Dim sBuffer As String
    Dim lSize As Long
    
    sBuffer = Space$(255)
    lSize = Len(sBuffer)
    GetComputerName sBuffer, lSize
    
    If lSize > 0 Then
        GetThisComputerName = Left$(sBuffer, lSize)
    End If
End Function

'Call example
mrc_wLog.Fields(7) = GetThisComputerName

Main form

The main form needs to add controls, but it also needs to use MDI form. Generally, the subform will cover the MDI form, so you need to call the procedure to solve this problem.

'statement
Public Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

    'Use examples
    frmInquiryLineRecord.Show
    Call SetParent(frmInquiryLineRecord.hWnd, FrmMain.hWnd)


Form display

How to display only one form?

Private Sub Form_Deactivate()

    If Me.WindowState <> 1 Then
        Me.WindowState = 1
    End If
End Sub

I hope my sharing can help you!
Thank you for reading, if you have a better way, welcome to share with me, thank you!

Posted by suz_1234 on Mon, 23 Dec 2019 07:14:11 -0800