Access the system registry using VB Functions

Source: Internet
Author: User

This article describes how to access the system registry using the four functions provided by VB.
Create a project and place two labels on Form1. The Caption attributes are "name" and "company", and the txtName and txtCompany Text attributes are set to null; the three command buttons are cmdSave, find, and delete. The Caption is set to save, view, and delete respectively ".
Add the following code to the three command buttons:

Private Sub cmdSave_Click ()
'Assigns the content in the two text boxes to Name and Company in the User area under MyApp respectively.
SaveSetting "MyApp", "User", "Name", txtName
SaveSetting "MyApp", "User", "Company", txtCompany
MsgBox "your information has been saved! ″
End Sub
Private Sub partition find_click ()
'Find the setting values of Name and Company in the User area of MyApp and display
MsgBox "Your name is:" & GetSetting ("MyApp", "User ″,
"Name") & Chr (13) & Chr (10) & "your company is :″
& GetSetting ("MyApp", "User", "Company ″)
End Sub
Private Sub partition delete_click ()
'Delete the User region under MyApp and all registry items under MyApp
DeleteSetting "MyApp", "User ″
End Sub

Run the program, enter the name and company name in the window, press "save", and then press "Search". The correct result is displayed, it indicates that the SAVE and search operations are normal. If you press the "Search" button before saving or after deletion, a dialog box is displayed, indicating that the registry key you are looking for does not exist.

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.