Valhalla Legends Forums Archive | General Programming | [VB] Check Range.

AuthorMessageTime
LordNevar
I use to have code for it and lost it during a format, and I haven't touched vb in awhile, so now I'm lost per say. I am trying to find numbers in a specific range.

Ex: 100-200

I want to only print those numbers in that range. If anyone has any data on how to do this it would be much appreciated.
December 13, 2005, 10:56 AM
Myndfyr
[code]
Dim i As Integer
For i = 100 to 200
  If NumberIsInRange(i) Then
  DoSomethingWithNumber i
  End If
Next
[/code]

??
December 13, 2005, 11:05 AM
LordNevar
Thankxs MyndFyre, that'll work.
December 13, 2005, 11:47 AM
JoeTheOdd
IIRC, dimensioning I as a Long will generally be a minute bit faster, as it will then allocate it to a long processor space (eax, ebx, ecx) instead of a memory space (AL, AH).
December 13, 2005, 10:52 PM
Myndfyr
[quote author=Joe link=topic=13497.msg137489#msg137489 date=1134514361]
IIRC, dimensioning I as a Long will generally be a minute bit faster, as it will then allocate it to a long processor space (eax, ebx, ecx) instead of a memory space (AL, AH).
[/quote]

Chances are since it's being used in a loop, unless VB is braindead, the counter will be in ECX anyway.  And using 16-bit registers isn't any slower than 32-bit registers; it's when you're accessing memory that are not aligned at the four byte offsets when memory access gets slow.
December 13, 2005, 10:59 PM
JoeTheOdd
VB is braindead, duh. =p

Hence the "IIRC", I figured I was probably wrong somewhere and didn't want to sound like an idiot.
December 14, 2005, 4:04 AM

Search