Click here to Skip to main content
15,889,654 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionbingind datagrid view problem Pin
H.A.Faheem12-Aug-09 23:22
H.A.Faheem12-Aug-09 23:22 
AnswerRe: bingind datagrid view problem Pin
Dave Kreskowiak13-Aug-09 2:03
mveDave Kreskowiak13-Aug-09 2:03 
QuestionSending Messages to HID Pin
Kobi_Z12-Aug-09 19:08
Kobi_Z12-Aug-09 19:08 
AnswerRe: Sending Messages to HID Pin
Dave Kreskowiak13-Aug-09 2:01
mveDave Kreskowiak13-Aug-09 2:01 
GeneralRe: Sending Messages to HID Pin
Kobi_Z19-Aug-09 2:25
Kobi_Z19-Aug-09 2:25 
GeneralRe: Sending Messages to HID Pin
Dave Kreskowiak19-Aug-09 12:11
mveDave Kreskowiak19-Aug-09 12:11 
QuestionCPU increase using Nullable Pin
captainmogo12-Aug-09 7:13
captainmogo12-Aug-09 7:13 
AnswerRe: CPU increase using Nullable Pin
Luc Pattyn12-Aug-09 8:20
sitebuilderLuc Pattyn12-Aug-09 8:20 
Hi,

nullable types don't come for free, they take more memory and more cycles, as they have to store and process the data that goes with the extra functionality (think of it as one extra boolean flag "hasValue",
it would double the footprint of an int, double the amount of data to be copied when performing nullable int=nullable int, etc).

you may have to account for changes in "hasValue" too; i.e. a variable that goes from "hasNoValue" to "hasValue" has definitely changed (and if you allow the reverse change, from "hasValue" to "hasNoValue", that would be a change too). So your history information should not be just "oldValue" but also "oldHasValue". Hence
Public shared Function HasChanged(ByVal val1 as Single, ByVal val2 as Nullable(Of Int32)) As Int16
IMO should be more like (I'm no VB expert!):
Public shared Function HasChanged(ByVal val1 as Nullable(Of Int32), ByVal val2 as Nullable(Of Int32)) As Bool
    if val1.HasValue AND val2.HasValue return val1<>val2   ' value changed
    if val1.HasValue <> val2.HasValue return True  ' hasValue changed
    return False  ' was and is without value
End Function


Some more remarks:
1. Try to avoid ToString. if Key is already a string, no need to call ToString on it.
2. I'm not sure having two different collections (one of them a HashTable/Dictionary) is wise; I would try and figure a way with just one. More in particular, if current value and previous value is a characteristic of your objects, I would incorporate that in the object itself, not delegate it to some HashTable. A simple For Each would then suffice.
3. While doing (2) I would not use nullable types, instead I would add an explicit bool flag to my objects. As I expect my code would be more efficient than the general-purpose nullable support (see first alinea).

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

modified on Wednesday, August 12, 2009 2:34 PM

GeneralRe: CPU increase using Nullable Pin
captainmogo12-Aug-09 9:12
captainmogo12-Aug-09 9:12 
GeneralRe: CPU increase using Nullable Pin
Luc Pattyn12-Aug-09 9:25
sitebuilderLuc Pattyn12-Aug-09 9:25 
Generalcolor test Pin
Luc Pattyn12-Aug-09 10:52
sitebuilderLuc Pattyn12-Aug-09 10:52 
GeneralRequire Project in VB with SQL server 2005/2008 Pin
jeshra27912-Aug-09 0:47
jeshra27912-Aug-09 0:47 
GeneralRe: Require Project in VB with SQL server 2005/2008 Pin
Henry Minute12-Aug-09 2:18
Henry Minute12-Aug-09 2:18 
GeneralRe: Require Project in VB with SQL server 2005/2008 Pin
Dave Kreskowiak12-Aug-09 2:18
mveDave Kreskowiak12-Aug-09 2:18 
GeneralRe: Require Project in VB with SQL server 2005/2008 Pin
0x3c012-Aug-09 2:37
0x3c012-Aug-09 2:37 
QuestionCustom cursor problem Pin
The real $M@11-Aug-09 22:29
The real $M@11-Aug-09 22:29 
AnswerRe: Custom cursor problem Pin
LloydA11112-Aug-09 1:56
LloydA11112-Aug-09 1:56 
GeneralRe: Custom cursor problem Pin
Henry Minute12-Aug-09 2:20
Henry Minute12-Aug-09 2:20 
QuestionRe: Custom cursor problem Pin
The real $M@14-Aug-09 2:36
The real $M@14-Aug-09 2:36 
AnswerRe: Custom cursor problem Pin
Henry Minute14-Aug-09 3:04
Henry Minute14-Aug-09 3:04 
GeneralRe: Custom cursor problem Pin
The real $M@15-Aug-09 1:55
The real $M@15-Aug-09 1:55 
GeneralRe: Custom cursor problem Pin
waterboarer25-Feb-10 9:11
waterboarer25-Feb-10 9:11 
QuestionHow to trigger a mouse click event on finding a specific text? Pin
Member 205660911-Aug-09 19:24
Member 205660911-Aug-09 19:24 
AnswerRe: How to trigger a mouse click event on finding a specific text? Pin
Johan Hakkesteegt11-Aug-09 22:10
Johan Hakkesteegt11-Aug-09 22:10 
AnswerRe: How to trigger a mouse click event on finding a specific text? Pin
Member 205660911-Aug-09 22:23
Member 205660911-Aug-09 22:23 

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.