Re: Error Handlers for VB6

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: YYZ (none_at_none.com)
Date: 03/23/05


Date: Wed, 23 Mar 2005 11:10:06 -0600


"Larry Serflaten" <serflaten@usinternet.com> wrote in message
news:eGjd5U8LFHA.4092@tk2msftngp13.phx.gbl...
>
> A clever fix is to create a class that you instantiate at the start of
> your routine.
> No matter how you exit that routine, VB will drop the reference to that
> class
> as it exits. You can use that fact to your advantage....

<snip>

> Private Sub Form_Click()
> Dim Cursor As HourGlass
> Set Cursor = New HourGlass
> ' Any and all code....
> MsgBox "Waiting..." 'to see it was set to HourGlass
> End Sub

That's nice. A question, though. I have stayed away from use dim X as New
Something in the past because I lose control of when VB creates an
object...and I can't set it to nothing because it will just be created again
if any code references it...

But in this case I think that this might not be an issue, and using Dim
Cursor as New HourGlass would make it a one-liner (Go Rick!) and eliminate
the possibility that I might forget the Set line.

Can you think of any reason why using Dim as New would be bad in this
situation?

Matt



Relevant Pages

  • Re: AddPicture in VBA without explict reference to a file path?
    ... Private Sub SetLinkedImagesLocalPath() ... ' This routine sets the new path for external links. ... Dim oRange As Word.Range ... Dim oField As Word.Field ...
    (microsoft.public.word.drawing.graphics)
  • RE: Routine running slow (memory leak?)
    ... In the first sub, ListAuditResults, I set up the 3 past ranges using the Set ... of no memory leak) as I need them all the time until the routine ends. ... it would never run again and I could put "Set Hardrng = Nothing" ... Dim PasteStartCell As String ...
    (microsoft.public.excel.programming)
  • Re: Cursors - Server Side - Only Forward?
    ... You're using VB's ADO.Recordset object to manipulate the cursor data. ... Using server side cursors would ... > Dim Dbs As New ADODB.Connection ... > ' Prepare SQL Select statement ...
    (microsoft.public.sqlserver.programming)
  • Re: StoryRanges, finding headers/footers
    ... Public Sub BatchReplaceAnywhere() ... Dim FirstLoop As Boolean ... 'This routine supplied by Peter Hewett ...
    (microsoft.public.word.vba.general)
  • Re: file delete routine is intermittent
    ... If I open the recycle bin and restore all, close and restart the application and run it again it ... Click the command button to run the routine a second time and then those left behind items are sent ... > Dim WFD As WIN32_FIND_DATA ... > Dim hFile As Long ...
    (microsoft.public.vb.winapi)