Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.



Public Function intRemoveKey(strFile As String, strSection As String, strKey As String, strKeyMax As String, intKeyRemove As Integer) As Integer
' Procedure :   intRemoveKey
' Description:  Remove a key from the INI file.
' Copyright:    Chris Greaves Inc.
' Inputs:       STRING file name of ini file
'               STRING section name within ini file
'               STRING key name within section
'               STRING name of key containing maximum key number
'               INTEGER key to be deleted.
' Returns:      A variant array of strings.
' Assumes:      None.
' Side Effects: None.
' Tested:       By the calls shown below.
' Method (an approach which lends its components to other appliactions)
'   (1) Load an internal array with all relevant keys from the INI file.
'   (2) Filter the nominated key during loading.
'   (3) Write the array back to the INI file.
    Dim strArrayKey() As String ' String array to hold the keys and values from the INI file.
    ReDim strArrayKey(0)
'   (1) Load an internal array with all relevant keys from the INI file.
    Dim intMaxKeys As Integer ' Obtain the current limit of keys
    intMaxKeys = Val(strGPA(strKeyMax, 0))
    Dim intKey As Integer ' Loop to load the array of keys
    For intKey = 0 To intMaxKeys
'   (2) Filter the nominated key during loading.
        If intKey <> intKeyRemove Then ' load the key to the array
            strArrayKey(UBound(strArrayKey)) = strGPA(strKey & Trim(str(intKey)), "")
            ReDim Preserve strArrayKey(UBound(strArrayKey) + 1)
        Else ' ignore the key
        End If
    Next intKey
    ReDim Preserve strArrayKey(UBound(strArrayKey) - 1)
'   (3) Write the array back to the INI file.
    For intKey = 0 To intMaxKeys - 1
        Call strPPA(strKey & Trim(str(intKey)), strArrayKey(intKey))
    Next intKey
    Call strPPA(strKeyMax, UBound(strArrayKey))
'Sub TESTintRemoveKey()
'MsgBox intRemoveKey("d:\20010330\script2k.ini", "series", "series", "numseries", 3)
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1

Visual Basic (VB and VBA)

Copyright 1999-2001 Christopher Greaves. All rights reserved.
Home Page and email to [email protected]
If in doubt, record a macro and inspect the entrails!

 

 

Please read the DISCLAIMER.

Here is an INDEX to all the procedures.

You will probably need one copy of my GLOBAL DECLARATIONS.

Public Function intRemoveKey(strFile As String, strSection As String, strKey As String, strKeyMax As String, intKeyRemove As Integer) As Integer
' Procedure :   intRemoveKey
' Description:  Remove a key from the INI file.
' Copyright:    Chris Greaves Inc.
' Inputs:       STRING file name of ini file
'               STRING section name within ini file
'               STRING key name within section
'               STRING name of key containing maximum key number
'               INTEGER key to be deleted.
' Returns:      A variant array of strings.
' Assumes:      None.
' Side Effects: None.
' Tested:       By the calls shown below.
' Method (an approach which lends its components to other appliactions)
'   (1) Load an internal array with all relevant keys from the INI file.
'   (2) Filter the nominated key during loading.
'   (3) Write the array back to the INI file.
    Dim strArrayKey() As String ' String array to hold the keys and values from the INI file.
    ReDim strArrayKey(0)
'   (1) Load an internal array with all relevant keys from the INI file.
    Dim intMaxKeys As Integer ' Obtain the current limit of keys
    intMaxKeys = Val(strGPA(strKeyMax, 0))
    Dim intKey As Integer ' Loop to load the array of keys
    For intKey = 0 To intMaxKeys
'   (2) Filter the nominated key during loading.
        If intKey <> intKeyRemove Then ' load the key to the array
            strArrayKey(UBound(strArrayKey)) = strGPA(strKey & Trim(str(intKey)), "")
            ReDim Preserve strArrayKey(UBound(strArrayKey) + 1)
        Else ' ignore the key
        End If
    Next intKey
    ReDim Preserve strArrayKey(UBound(strArrayKey) - 1)
'   (3) Write the array back to the INI file.
    For intKey = 0 To intMaxKeys - 1
        Call strPPA(strKey & Trim(str(intKey)), strArrayKey(intKey))
    Next intKey
    Call strPPA(strKeyMax, UBound(strArrayKey))
'Sub TESTintRemoveKey()
'MsgBox intRemoveKey("d:\20010330\script2k.ini", "series", "series", "numseries", 3)
'End Sub
End Function

We all knew nothing when we started …
Home Page and Contact Information
Send email to [email protected].
This page was last updated Thursday, November 15, 2001

 

 

Hosted by www.Geocities.ws

1