473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Stupid question

I junt can't figures this out. Can somebody help.

I have list of numbers
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
and so on
I want to define some range like
1-500
501-1000
1001-1500
1501-2000
....
What I need is how to find which number in which range belongs.
Can someone help?

TIA
Nov 21 '05 #1
8 996
School homework?

for a number t, t belongs to the range m..n if t >= m and t <= n!

"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
I junt can't figures this out. Can somebody help.

I have list of numbers
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
and so on
I want to define some range like
1-500
501-1000
1001-1500
1501-2000
...
What I need is how to find which number in which range belongs.
Can someone help?

TIA

Nov 21 '05 #2
I need the ranges to be generate dynamilcy, but in the way I have showed in
previews post
1-500
501-1000
1001-1500


"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ck*******************@news.demon.co.uk...
School homework?

for a number t, t belongs to the range m..n if t >= m and t <= n!

"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
I junt can't figures this out. Can somebody help.

I have list of numbers
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
and so on
I want to define some range like
1-500
501-1000
1001-1500
1501-2000
...
What I need is how to find which number in which range belongs.
Can someone help?

TIA


Nov 21 '05 #3
The question doesn't make sense.

"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:em**************@TK2MSFTNGP14.phx.gbl...
I need the ranges to be generate dynamilcy, but in the way I have showed in
previews post
1-500
501-1000
1001-1500


"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ck*******************@news.demon.co.uk...
School homework?

for a number t, t belongs to the range m..n if t >= m and t <= n!

"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
I junt can't figures this out. Can somebody help.

I have list of numbers
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
and so on
I want to define some range like
1-500
501-1000
1001-1500
1501-2000
...
What I need is how to find which number in which range belongs.
Can someone help?

TIA



Nov 21 '05 #4
>"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ck*******************@news.demon.co.uk...
School homework?

for a number t, t belongs to the range m..n if t >= m and t <= n!

On Mon, 11 Oct 2004 17:19:00 +0300, "Nikolay Petrov" <jo******@mail.bg>
wrote:
I need the ranges to be generate dynamilcy, but in the way I have showed in
previews post
1-500
501-1000
1001-1500


Robin gave you an answer that will work; it's even almost in
pseudo-code. Use your brain and translate it into real code.
--
auric underscore underscore at hotmail dot com
*****
- What the hell is *that*?
- It's my iMac. Cool, huh?
- Does Willy Wonka know you took this out of his office?
Nov 21 '05 #5
Nikolay,
You can use a Select Case if you have fixed ranges, otherwise I would
probably use an IntegerRange class.

http://www.martinfowler.com/ap2/range.html

Something like:

Dim range1 As New IntegerRange(1, 500)
Dim range2 As New IntegerRange(501, 1000)
Dim range3 As New IntegerRange(1001, 1500)
Dim range4 As New IntegerRange(1501, 2000)

Dim value As Integer = 100

If range1.Contains(value) Then
' do stuff for 1-500
ElseIf range2.Contains(value) Then
' do stuff for 501-1000
ElseIf range3.Contains(value) Then
' do stuff for 1001-1500
ElseIf range4.Contains(value) Then
' do stuff for 1501-2000
End If

Where range1, range2, range3, range4 are individually part of another
abstraction (class) that could work polymophically based on an overridable
"Action" method, I would then put this other abstraction into a collection
and simply iterate the collection looking for a specific range & call the
"Action" method of the object that was found... Note the "Action" method
could simply be a Delegate, then this second abstraction would simply need
to be an IntegerRange & Delegate pair.
Public Structure IntegerRange

Private ReadOnly m_start As Integer
Private ReadOnly m_finish As Integer

Public Sub New(ByVal start As Integer, ByVal finish As Integer)
If start > finish Then Throw New ArgumentException("Start cannot be
after finish")
m_start = start
m_finish = finish
End Sub

Public ReadOnly Property Start() As Integer
Get
Return m_start
End Get
End Property

Public ReadOnly Property Finish() As Integer
Get
Return m_finish
End Get
End Property

Public ReadOnly Property Duration() As Integer
Get
Return m_finish - m_start
End Get
End Property

Public Function Contains(ByVal value As Integer) As Boolean
Return (m_start <= value AndAlso value <= m_finish)
End Function

End Structure

Hope this helps
Jay

"Nikolay Petrov" <jo******@mail.bg> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
I junt can't figures this out. Can somebody help.

I have list of numbers
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
and so on
I want to define some range like
1-500
501-1000
1001-1500
1501-2000
...
What I need is how to find which number in which range belongs.
Can someone help?

TIA

Nov 21 '05 #6
Here's an easy set-based solution

use tempdb
go
set nocount on
create table t1 (col1 int not null)
insert t1 values (1)
insert t1 values (3)
insert t1 values (6)
insert t1 values (6)
insert t1 values (8)
insert t1 values (9)
insert t1 values (10)
insert t1 values (11)
insert t1 values (12)
insert t1 values (25)
insert t1 values (30)
insert t1 values (95)
insert t1 values (350)
create table t2 (lowerRange int not null)
insert t2 values (0)
insert t2 values (5)
insert t2 values (10)
insert t2 values (15)
insert t2 values (20)
insert t2 values (25)
insert t2 values (30)
select c.lowerRange, c.upperRange, count(d.col1) as Cnt
from (
select a.lowerRange + 1 as LowerRange, min(b.lowerRange) as UpperRange
from t2 a
left join t2 b
on a.lowerRange < b.lowerRange
group by a.lowerRange
) c
left join t1 d
on d.col1 >= c.lowerRange and d.col1 <= coalesce(c.UpperRange, 999)
group by c.lowerRange, c.upperRange

drop table t1
drop table t2

hth,
Eric

Nikolay Petrov wrote:
I junt can't figures this out. Can somebody help.

I have list of numbers
00000001
00000002
00000003
00000004
00000005
00000006
00000007
00000008
and so on
I want to define some range like
1-500
501-1000
1001-1500
1501-2000
...
What I need is how to find which number in which range belongs.
Can someone help?

TIA

Nov 21 '05 #7

"Robin Tucker" <id*************************@reallyidont.com> wrote in
message news:ck*******************@news.demon.co.uk...
The question doesn't make sense.


He couldn't explain it in the VB6 group either.... (Or at least not WHY he
wanted to do it.)
Nov 21 '05 #8
I have managed to do it by myself.
However thank you all for your time.

Nov 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

119
by: rhat | last post by:
I heard that beta 2 now makes ASP.NET xhtml compliant. Can anyone shed some light on what this will change and it will break stuff as converting HTML to XHTML pages DO break things. see,...
5
by: raz | last post by:
Greetings all. I apologize for what is almost certainly a stupid question, but I can't figure this out, and have no more time for head bashing... The short version: what is the appropriate...
4
by: IS | last post by:
At the recommendation of several people in this newsgroup I have downloaded two or three Compilers. One is the Beta version of Microsoft's Visual C++ 2005. I have entered a complete beginner code...
2
by: Ron Weldy | last post by:
I read that you don't need .cs files to deploy but I suppose if you are trying to reconstruct someone's work, you will need these files. Is that correct?
3
by: rroman | last post by:
I have a very simple form, takes information from the user, updates a SQL database, now I just want to redirect to a "Thank You For Your Time" web page within the same bowser. ASP. NET VB
6
by: Adam Smith | last post by:
I have posted this and similar questions repeatedly and can't even raise a single response. I am being led to believe that this then 'Must be a stupid question' although people say that there is no...
5
by: Alberto Salvati | last post by:
Hi, List. My company has a VERY BIG product base on db2 udb v7.x. We want to di an upgrade to v9, but.... current db has a lot of procedure (cobol..!). Therefore, we've planned to rewrite this...
2
by: Lynx101 | last post by:
Hi, Is this a stupid question? Senario: Two tables linked together with an ID number. Question: When using a combo box, which refences another table by indexed autonumber, is there a way to...
9
by: AWW | last post by:
Running XP - Visual Studio 2005 - VB Want to have duplicate projects - one safe and stable - other for experimenting Can't fine easy way to make duplicate project. Stupid question? or stupid ME?...
9
by: Alec | last post by:
Sorry guys, stupid question.... Am no programming expert and have only just started using php for creating dynamic news pages. Then I see a dynamic website without the php extension. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.