Click here to Skip to main content
15,888,968 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
JokeRe: Looking at this math is making me num... Pin
Perspx4-Sep-08 9:36
Perspx4-Sep-08 9:36 
GeneralRe: Looking at this math is making me num... Pin
Pete O'Hanlon4-Sep-08 10:43
mvePete O'Hanlon4-Sep-08 10:43 
GeneralRe: Looking at this math is making me num... Pin
ClementsDan4-Sep-08 18:24
ClementsDan4-Sep-08 18:24 
JokeRe: Looking at this math is making me num... Pin
AeonBlue5-Sep-08 4:07
AeonBlue5-Sep-08 4:07 
GeneralWhy is the app so slow Pin
BadKarma3-Sep-08 3:11
BadKarma3-Sep-08 3:11 
GeneralRe: Why is the app so slow Pin
Paul Conrad3-Sep-08 6:24
professionalPaul Conrad3-Sep-08 6:24 
GeneralRe: Why is the app so slow Pin
Graham Bradshaw3-Sep-08 6:28
Graham Bradshaw3-Sep-08 6:28 
GeneralRe: Why is the app so slow Pin
BadKarma3-Sep-08 7:53
BadKarma3-Sep-08 7:53 
Graham Bradshaw wrote:
In the original coders defense, if there (previously) was a condition around the ReDim / nFoo = / j = lines, the logic makes perfect sense.


Actually in one of the three cases this was true, but then one could do it like this (which is what i chose)

j = 0
ReDim nFoo(lvwCardGrp.ListItems.Count - 1)
For i = 1 To lvwCardGrp.ListItems.Count
  if some_condition then
    nFoo(j) = Mid$(lvwCardGrp.ListItems(i).Key, 3)
    j = j + 1
  endif
Next
ReDim nFoo(j - 1)

In this case only one allocation happens. And in the end free up the unnecessary space, without the preserve statement which needs to copy the data to a new location.

Learn from the mistakes of others, you may not live long enough to make them all yourself.

GeneralRe: Why is the app so slow Pin
Graham Bradshaw3-Sep-08 9:36
Graham Bradshaw3-Sep-08 9:36 
GeneralRe: Why is the app so slow Pin
BadKarma3-Sep-08 20:35
BadKarma3-Sep-08 20:35 
GeneralRe: Why is the app so slow Pin
PIEBALDconsult3-Sep-08 8:06
mvePIEBALDconsult3-Sep-08 8:06 
GeneralRe: Why is the app so slow Pin
Graham Bradshaw3-Sep-08 9:31
Graham Bradshaw3-Sep-08 9:31 
GeneralRe: Why is the app so slow Pin
PIEBALDconsult3-Sep-08 11:28
mvePIEBALDconsult3-Sep-08 11:28 
GeneralRe: Why is the app so slow Pin
Pete O'Hanlon3-Sep-08 9:15
mvePete O'Hanlon3-Sep-08 9:15 
GeneralIf True = False Then Pin
Dan Neely2-Sep-08 5:31
Dan Neely2-Sep-08 5:31 
GeneralRe: If True = False Then Pin
PIEBALDconsult2-Sep-08 7:14
mvePIEBALDconsult2-Sep-08 7:14 
GeneralRe: If True = False Then Pin
Dan Neely2-Sep-08 7:44
Dan Neely2-Sep-08 7:44 
GeneralRe: If True = False Then Pin
PIEBALDconsult2-Sep-08 9:34
mvePIEBALDconsult2-Sep-08 9:34 
GeneralRe: If True = False Then Pin
Rob Grainger3-Sep-08 22:10
Rob Grainger3-Sep-08 22:10 
GeneralRe: If True = False Then Pin
Vasudevan Deepak Kumar4-Sep-08 12:27
Vasudevan Deepak Kumar4-Sep-08 12:27 
GeneralRe: If True = False Then Pin
BillW332-Sep-08 8:45
professionalBillW332-Sep-08 8:45 
GeneralRe: If True = False Then Pin
Dan Neely2-Sep-08 9:42
Dan Neely2-Sep-08 9:42 
GeneralRe: If True = False Then Pin
Star Vega3-Sep-08 1:41
Star Vega3-Sep-08 1:41 
GeneralRe: If True = False Then Pin
ednrg2-Sep-08 8:59
ednrg2-Sep-08 8:59 
GeneralRe: If True = False Then Pin
GibbleCH2-Sep-08 9:01
GibbleCH2-Sep-08 9:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.