Click here to Skip to main content
15,913,055 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: string to double Pin
Moreno Airoldi13-Aug-09 0:42
Moreno Airoldi13-Aug-09 0:42 
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 
I have a sorted list that stores current values of 3 different data types. I also have a hash table that holds the previous value of each data point. I need to compare the newest value to the previous value and store any ones that change to a list. This has been working fine for months but a new requirement was added making some of the values = nothing and this is where my problems began

Previous code

For each de as DictionaryEntry in serialData
name = de.Key.Tostring
If ValueChanged(de.Value, hash.Item(name),de.value.GetType.Name = 1 Then
... add new value to list
... replace value is hash table with new value
End If

Public Function ValueChanged(Byval val1 as Object, ByVal val2 as Object, ByVal typ as String) as Int16

Select Case typ
Case "Single"
Dim newVal, lastVal as Single
newVal = val1
lastVal = val2

If Not newVal = lastVal then 
Return 1
Else 
Return 0
End If

Case "UInt32"
.... same

Case "Int32"
.... same

End Select


For the new requirement, I added a If val1 = Nothing Then Return 1 but now this line returns true when val2 = 0.0 making the function return 1 which I dont want. 0.0 should not be equal to nothing. I also tried using Nullable types

Public shared Function HasChanged(ByVal val1 as Single, ByVal val2 as Nullable(Of Single)) As Int16 
If val2.HasValue Then 
If val1 = val2 Then
Return 0 
Else 
Return 1
End if 
Else 
Return 1
End if

Public shared Function HasChanged(ByVal val1 as Single, ByVal val2 as Nullable(Of Int32)) As Int16 
If val2.HasValue Then 
If val1 = val2 Then
Return 0 
Else 
Return 1
End if 
Else 
Return 1
End if

Public shared Function HasChanged(ByVal val1 as Single, ByVal val2 as Nullable(Of UInt32)) As Int16 
If val2.HasValue Then 
If val1 = val2 Then
Return 0 
Else 
Return 1
End if 
Else 
Return 1
End if


but this increases my CPU from 3% to 56%! Any idea what I could be doing wrong. I am in a time crunch
AnswerRe: CPU increase using Nullable Pin
Luc Pattyn12-Aug-09 8:20
sitebuilderLuc Pattyn12-Aug-09 8:20 
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 

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.