Results 1 to 11 of 11
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    deleteSetting (registry) (Excel97/SR2)

    The help files tell me "However, the DeleteSetting statement does nothing if the specified section or key setting does not exist.", but in my experince running their example code delivers me a run-time error '5".

    My code is working fine (thanks!), and I could trap this with an On Error, but I'm wondering if I've misundertood something?

    <pre>Sub test()
    DeleteSetting "MyApp", "Startup"
    End Sub
    </pre>


  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: deleteSetting (registry) (Excel97/SR2)

    I think the implication is that the command won't delete anything else, not that it won't raise an error, Chris. It is customary to get a setting first to determine if it exists.
    Charlotte

  3. #3
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: deleteSetting (registry) (Excel97/SR2)

    VBA Help file says:

    <hr>If all arguments are provided, the specified setting is deleted. A run-time error occurs if you attempt to use the DeleteSetting statement on a non-existent section or key setting.<hr>
    Looking at some code I have that uses the DeleteSetting statement, the error handler specifies Err 5. This appears to be normal behavior.

    HTH

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleteSetting (registry) (Excel97/SR2)

    NIMHF (Not In My help File!) Are you reading from Excel97/SR2?


    Deletes a section or key setting from an application's entry in the Windows registry.

    Syntax

    DeleteSetting appname, section[, key]

    The DeleteSetting statement syntax has these named arguments:

    Part Description
    appname Required. String expression containing the name of the application or project to which the section or key setting applies.
    section Required. String expression containing the name of the section where the key setting is being deleted. If only appname and section are provided, the specified section is deleted along with all related key settings.
    key Optional. String expression containing the name of the key setting being deleted.
    Remarks

    If all arguments are provided, the specified key setting is deleted. However, the DeleteSetting statement does nothing if the specified section or key setting does not exist.

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: deleteSetting (registry) (Excel97/SR2)

    They must have written that documentation before they realized what a stupid result that would be. Or maybe it was some kind of inside joke, you know, office politics.

  6. #6
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: deleteSetting (registry) (Excel97/SR2)

    No, I was using the 2K version of VBA Help files. They must've updated the "Remarks" for DeleteSetting. See attached pic from VBA Help.

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleteSetting (registry) (Excel97/SR2)

    > inside joke, you know, office politics.

    I know.

    I've suspected for a long time that my name got transferred from the old Microsoft BBS here in Mississauga, and when I asked for the SR2 they decided to get even. I knew I should've used Dr Katz's name....

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: deleteSetting (registry) (Excel97/SR2)

    > , I was using the 2K version of VBA Help files.

    Thanks for this confirmation.

    There are days when I think I'm losing my mind, .... and I hate On Error with a passion!

  9. #9
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: On Error GoTo Hell!

    In reference to your comment:
    <hr>and I hate On Error with a passion!<hr>
    (Somewhat off-topic) - that reminds me of a good essay/article on error handling that appeared in Advanced Microsoft Visual Basic 6.0, Second Edition, by The Mandelbrot Set (International) Ltd, published by MS Press, 1998:

    On Error GoTo Hell - A Methodical Approach to Error Handling

    (The linked article is in PDF format.) "The Mandelbrot Set" is a group of developers who named themselves for the well known (to mathematicians, anyway) Mandelbrot Set, a fractal set named after mathematician Benoit Mandelbrot. I don't know if you'd actually want to expend the effort required to adapt the concepts expressed in article (or just to read the whole thing - it is rather lengthy), but you gotta admit, that's a great title.... just label your error-handling code block as "Hell:" Then you can enhance your dull, boring VBA routines with feisty "On Error GoTo Hell" statements...

    HTH

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: On Error GoTo Hell!

    > a good essay/article on error handling

    Thanks. A GREAT reference. I enjoyed (and will probably implement) assertions, especially near the user interfaces. His discussion of p39 held me.

    I made a post a few months ago on why I felt that "On Error" was bad, although, after reading the article, I can see that if it is done properly, it has advantages. Doingit properly is probably way too expensive for most folks.

    My understanding of VB.NET is that On Error will be kaput.

  11. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: On Error GoTo Hell!

    In VB.Net, you use a Try ... Catch construction to trap and handle errors and you can have multiple Try-Catch constructions in a routine. You can even nest them.
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •