home *** CD-ROM | disk | FTP | other *** search
-
- Private Sub cmdUpdate_Click()
-
- ' Make sure both a key name and a section name
- ' have been specified by the user.
- If txtSectionName.Text = "" Then
- MsgBox "Please enter a section name first."
- Exit Sub
- End If
- If txtKeyName.Text = "" Then
- MsgBox "Please enter a key name first."
- Exit Sub
- End If
-
- ' For INI files, call the INIUpdate function. For
- ' the Registry, call the RegUpdate function.
- If optType(0).Value = True Then
- lblStatus = INIUpdate
- Else
- lblStatus = RegUpdate
- End If
-
- End Sub
-
-
- Private Function INIUpdate() As String
-
- Dim lonStatus As Long
- Dim strSectionName As String
-
- ' Remove brackets from section name, if necessary
- strSectionName = FixSectionName(txtSectionName.Text)
-
- ' Use the WritePrivateProfileString API function to
- ' update the key.
- lonStatus = WritePrivateProfileString(strSectionName, _
- txtKeyName.Text, txtValue.Text, dlgGetFilename.FileName)
-
- ' Display the status of the operation and update
- ' the file contents list box if successful.
- If lonStatus = 0 Then
- INIUpdate = "Error - Key could not be updated"
- Else
- INIUpdate = "Key updated successfully"
- ReadFile
- End If
-
- End Function
-