Valhalla Legends Archive

Programming => General Programming => Topic started by: LordNevar on December 13, 2005, 04:56 AM

Title: [VB] Check Range.
Post by: LordNevar on December 13, 2005, 04:56 AM
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.
Title: Re: [VB] Check Range.
Post by: MyndFyre on December 13, 2005, 05:05 AM

Dim i As Integer
For i = 100 to 200
  If NumberIsInRange(i) Then
   DoSomethingWithNumber i
  End If
Next


??
Title: Re: [VB] Check Range.
Post by: LordNevar on December 13, 2005, 05:47 AM
Thankxs MyndFyre, that'll work.
Title: Re: [VB] Check Range.
Post by: Joe[x86] on December 13, 2005, 04:52 PM
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).
Title: Re: [VB] Check Range.
Post by: MyndFyre on December 13, 2005, 04:59 PM
Quote from: Joe on December 13, 2005, 04:52 PM
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).

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.
Title: Re: [VB] Check Range.
Post by: Joe[x86] on December 13, 2005, 10:04 PM
VB is braindead, duh. =p

Hence the "IIRC", I figured I was probably wrong somewhere and didn't want to sound like an idiot.