If statments

Rogy

Member
Joined
Nov 4, 2010
Messages
6
Programming Experience
Beginner
Is there a way to check if ther was a change in a interger that i can use in a if statment?
 
Hmm maybe this:

VB.NET:
Dim myinteger As Integer = Convert.ToInt32(MyTextBox.Text)
Dim originalvalue As Integer = myinteger

' i assume you do something here

If myinteger = somevalue AndAlso Integer.Equals(myinteger, originalvalue) Then
       ' do something here
End If

Actually i don't understand your question completely so can you rephrase it please?
 
So I have a value that changes I want to program to do something when the number changes

So basicly the change in number trigers something

(Never been good at explaining :/)
 
I think you create a tempuary Integer variable, you may declare it as a static variable and global. Then asign the integer initial value to it before using it. so u can determine if there is changes by comparing the tempuary integer variable and the main integer.

Dim tempinteger As Integer 'type at the class level to make it global
'new procedure
Dim maininteger As Integer
'maininteger may get its initial value
'whether after a procedure
tempinteger = maininteger 'tempuarilly storing the initial value
'code the sub that may change the integer value
If tempinteger <> maininteger Then 'if statement to determine if their is a changes
'there is changes
Else
'no changes
End If


if am not missinterpreting your question, but this i my opinion
 
Personally, I would create a private variable (type: integer) and in the setter check the incomming value against the variable, if they're different I would then set the variable to the value & raise an event.

Then in the code instead of using the variable I would use the new property. That way, whenever the property is set, if different you can fire an event to run some code that does something with it.
 
Back
Top