smartcat99s wrote:
I'd just add a variable that indicates the direction that you're heading.
Then it's just a nested if statement.
Note: I'm not familiar with VB. The code provided below is generic and will almost certainly need to be corrected to produce proper VB code. I'll keep it as simple as possible so you can plug it in as quickly as possible.
Smarcat: Great idea.
If you make the variable + or -1, then the variable holds the 'direction' that you are counting (-1, obviously, means you are 'counting' down). You could just add the 'direction' variable to your count and it will either increment or decrement depending on whether the value is positive or negative.
So, rather than having a series of if .. then conditionals, your counter would be simply:
Code:
Counter = Counter + Direction
Somewhere, you'll need to check to see whether the direction needs to change (ie., whether Text1.Text is < 0 or > 2047). This code will set the Direction variable accordingly:
Code:
If Counter = 0 Then Direction = 1
Else if Counter = 2047 Then Direction = -1
End if
This would best be implemented as a function whose parameters are the integer (Counter) being tested and the Direction that may change.
I hope that that helps, Ron.