Code reconstruction-Essay (1)

Source: Internet
Author: User
Original code: If txtschool. Text = "" then
Msgbox "Enter the registration unit! ", Vbinformation
Checkregtext = false
Txtschool. setfocus
Exit Function
End if

1: Len (txtschool. Text) is much faster than txtschool. Text =.

2: Add trim to txtschool. Text

3: remove the TXT school repetition.

Result:

1: stringisempty function 'determines whether the string length is null
Public Function stringisempty (byref sstring as string) as Boolean
Sstring = trim (sstring)
Stringisempty = Len (sstring) = 0
End Function

2: The textboxisempty function 'text box is empty.
Private function textboxisempty (otextbox as Textbox, smessage as string) as Boolean
If stringisempty (otextbox. Text) then
Msgbox smessage, vbinformation
Otextbox. setfocus
Textboxisempty = true
End if
End Function

3: Final Result: If textboxisempty (txtperson, "Enter the registrant! ") Then exit function

If textboxisempty (txtconn, "Enter the contact number! ") Then exit function

If textboxisempty (txtschool, "Enter the registration unit! ") Then exit function

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.