.Net Code Monkey RSS 2.0
 Wednesday, December 03, 2008

Today I realised it was my poor coding that had created a subltle bug that the test team spotted yesterday.

The Bug

The bug was that Excel itself would crash if there was more than one instance of Excel open with my workbook application in one instance and another workbook application in the other and the user attempted to close my workbook via the grey [X].

The Cause

It turned out to be beacuse I had lazily shown and hidden some form objects rather than creating instances of the forms and opening and closing them and clearing up properly by setting these instances to nothing via a call in the "Workbook_BeforeClose" event when the workbook is finished with.

The solution

Once I re-wrote the form handling to be carried out within a "Dialog Manager" module, to work like a static class in C#, with private fields for each form and public properties to access them, the bug seemed to disappear.

Discussions here indicated it would probably be due to undisposed of form refences being present when the workbook is closed. If you have anything further you can add to this issue, please comment below.

Wednesday, December 03, 2008 12:38:34 PM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Excel | VBA | Bug
 Tuesday, December 02, 2008

I have recently been lumped with quite a bit of Excel based tasks to do at work, and there is one function that I keep needing that does not appear to be in VBA. "AverageIf"

Knowing that you can perform the equivelant of an AverageIf with combination of SumIf() and CountIf(), I thought I'd wrap these up in a function.

'Purpose:
'   Like Excel's sum if function put performs an average, rather than a sum.
'
Public Function AVGIF(ByVal checkRange As Range, ByVal criteria As Variant, ByVal avgRange As Range) As Variant

    Dim sumIfResult As Double
    Dim countIfResult As Double

    sumIfResult = Application.WorksheetFunction.SumIf(checkRange, criteria, avgRange)
    countIfResult = Application.WorksheetFunction.CountIf(checkRange, criteria)

    If countIfResult = 0 Then
        AVGIF = 0
    Else
        AVGIF = sumIfResult / countIfResult
    End If

End Function

I hope some one finds this as useful as I have.

 

Tuesday, December 02, 2008 5:01:14 PM (GMT Standard Time, UTC+00:00)  #    Comments [4] -
VBA | Excel
 Sunday, November 30, 2008

Mixing with one deck using Serato Scratch Lives Input reverse function

Below is a clip of a simple demonstration to show how you can use the Input Reverse function in Serato Scratch Live to mix with just one deck.

It may be useful if you can you break a needle during a set, or one deck is off for repair / servicing, or you have completely ruined one of the TCVs, There are any number of reasons that may lead you to have just one serviceable deck!

I hope it may help someone out of a sticky situation. sometime. Thank you for watching.

Tracks played:
Stir Fry - Breakin on the streets
The Soul of Man  -Scatterbox
Plump DJs - Weighed Down

You Tube Clip Link

Sunday, November 30, 2008 9:58:03 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
Scratch Live | Serato
 Saturday, November 15, 2008

Another discovery today, courtesy of Google finding Rik Robinson's Blog is String.TrimStart() and String.TrimEnd().

To trim a leading slash of a string or path use:

myString = myString.TrimStart(new char[]{'\\', '/'}); 

 

To trim a trailing slash of a string or path use:

myString = myString.TrimEnd(new char[]{'\\', '/'}); 

 

I had previously been using a much more long-winded approach. Cheers Rik for bringing that to my attention.

Saturday, November 15, 2008 11:17:15 AM (GMT Standard Time, UTC+00:00)  #    Comments [0] -
.Net | C#
Archive
<December 2008>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
Blogroll
 Clemens Vasters
 Harry Pierson
Passion * Technology * Ruthless Competence
 Joshua Flanagan
A .NET Software Developer
 Michael Schwarz's Blog
Developing applications on the Microsoft platform since Windows 3.1!
 Omar Shahine
Yet another Microsoft blogger
 Scot GU
Scott Guthrie lives in Seattle and builds a few products for Microsoft
 Scott Hanselman
Programming Life and the Zen of Computers
 Tom Mertens
Tom's corner
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Duane Wingett
Sign In
Statistics
Total Posts: 39
This Year: 4
This Month: 0
This Week: 0
Comments: 39
Themes
Pick a theme:
All Content © 2012, Duane Wingett
DasBlog theme 'Business' created by Christoph De Baene (delarou)