473,387 Members | 1,486 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,387 software developers and data experts.

missing number

le0
Hello guys,

Im really having a hard time doing this, I have a record set with the ItemNo
field with the data type as Text. In the record that I have, I want to find
the missing number in the series

for example:
1
3
4.1
4.2
5
missing number is 2.

How can I display the missing number in the browser or give me a return
value that notifies me that there is a missing number in the series. Is
there any function for that? Or how can i do that using a loop?

btw im using ASP Classic and MS Access Database

Leo :(
Aug 25 '06 #1
5 2428
"le0" <le*********@gmail.comwrote in message
news:#2**************@TK2MSFTNGP02.phx.gbl...
Hello guys,

Im really having a hard time doing this, I have a record set with the
ItemNo
field with the data type as Text. In the record that I have, I want to
find
the missing number in the series

for example:
1
3
4.1
4.2
5
missing number is 2.

How can I display the missing number in the browser or give me a return
value that notifies me that there is a missing number in the series. Is
there any function for that? Or how can i do that using a loop?

btw im using ASP Classic and MS Access Database
How do you define "missing"? Wouldn't 4 also be missing?
Also, as a text field, might it contain non-numeric values?

One approach might be to read all the ItemNo values
(SELECT ItemNo FROM {your_table} ORDER BY ItemNo)
determine the lowest and the highest numbers as integers
then loop throught the recordset to identify what's missing.
Aug 25 '06 #2
"McKirahan" <Ne**@McKirahan.comwrote in message
news:rK******************************@comcast.com. ..
"le0" <le*********@gmail.comwrote in message
news:#2**************@TK2MSFTNGP02.phx.gbl...
Hello guys,

Im really having a hard time doing this, I have a record set with the
ItemNo
field with the data type as Text. In the record that I have, I want to
find
the missing number in the series

for example:
1
3
4.1
4.2
5
missing number is 2.

How can I display the missing number in the browser or give me a return
value that notifies me that there is a missing number in the series. Is
there any function for that? Or how can i do that using a loop?

btw im using ASP Classic and MS Access Database

How do you define "missing"? Wouldn't 4 also be missing?
Also, as a text field, might it contain non-numeric values?
Also, will the first and lowest number always be 1 and will it exist?

Here's one solution. Watch for word-wrap.

<% @Language="VBScript" %>
<% Option Explicit
'*
'* Declare Constants
'*
Const cASP = "ItemNo.asp"
Const cMDB = "ItemNo.mdb"
Const cDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
'*
'* Declare Variables
'*
Dim intITM
Dim strITM
strITM = "Numbers present: "
Dim intNUM
intNUM = 0
Dim strNUM
strNUM = "Numbers missing: "
Dim strSQL
strSQL = "SELECT ItemNo From ItemNo ORDER BY ItemNo"
'*
'* Declare Objects
'*
Dim objADO
Set objADO = Server.CreateObject("ADODB.Connection")
objADO.Open cDSN & Server.MapPath(cMDB)
Dim objRST
Set objRST = objADO.Execute(strSQL)
'*
'* Read Recordset
'*
Do While Not objRST.EOF
intNUM = intNUM + 1
strITM = strITM & "<br>" & objRST("ItemNo").Value
intITM = Int(objRST("ItemNo").Value)
If intNUM < intITM Then
For intNUM = intNUM To (intITM-1)
strNUM = strNUM & "<br>" & intNUM
Next
End If
intNUM = intITM
objRST.MoveNext
Loop
'*
'* Destroy Objects
'*
Set objRST = Nothing
objADO.Close
Set objADO = Nothing
%>
<html>
<head>
<title><%=cASP%></title>
</head>
<body>
<%=strITM%>
<hr>
<%=strNUM%>
</body>
</html>
Aug 25 '06 #3
le0

"McKirahan" <Ne**@McKirahan.comwrote in message
news:gt******************************@comcast.com. ..
"McKirahan" <Ne**@McKirahan.comwrote in message
news:rK******************************@comcast.com. ..
>"le0" <le*********@gmail.comwrote in message
news:#2**************@TK2MSFTNGP02.phx.gbl...
Hello guys,

Im really having a hard time doing this, I have a record set with the
ItemNo
field with the data type as Text. In the record that I have, I want to
find
the missing number in the series

for example:
1
3
4.1
4.2
5
missing number is 2.

How can I display the missing number in the browser or give me a return
value that notifies me that there is a missing number in the series. Is
there any function for that? Or how can i do that using a loop?

btw im using ASP Classic and MS Access Database

How do you define "missing"? Wouldn't 4 also be missing?
Also, as a text field, might it contain non-numeric values?

Also, will the first and lowest number always be 1 and will it exist?

Here's one solution. Watch for word-wrap.

<% @Language="VBScript" %>
<% Option Explicit
'*
'* Declare Constants
'*
Const cASP = "ItemNo.asp"
Const cMDB = "ItemNo.mdb"
Const cDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
'*
'* Declare Variables
'*
Dim intITM
Dim strITM
strITM = "Numbers present: "
Dim intNUM
intNUM = 0
Dim strNUM
strNUM = "Numbers missing: "
Dim strSQL
strSQL = "SELECT ItemNo From ItemNo ORDER BY ItemNo"
'*
'* Declare Objects
'*
Dim objADO
Set objADO = Server.CreateObject("ADODB.Connection")
objADO.Open cDSN & Server.MapPath(cMDB)
Dim objRST
Set objRST = objADO.Execute(strSQL)
'*
'* Read Recordset
'*
Do While Not objRST.EOF
intNUM = intNUM + 1
strITM = strITM & "<br>" & objRST("ItemNo").Value
intITM = Int(objRST("ItemNo").Value)
If intNUM < intITM Then 'COMMENT: your condition here is always
false
For intNUM = intNUM To (intITM-1)
strNUM = strNUM & "<br>" & intNUM
Next
End If
intNUM = intITM
objRST.MoveNext
Loop
'*
'* Destroy Objects
'*
Set objRST = Nothing
objADO.Close
Set objADO = Nothing
%>
<html>
<head>
<title><%=cASP%></title>
</head>
<body>
<%=strITM%>
<hr>
<%=strNUM%>
</body>
</html>


Aug 25 '06 #4
"le0" <le*********@gmail.comwrote in message
news:uw**************@TK2MSFTNGP05.phx.gbl...

[snip]

It appears that your last post was incomplete;
that is, you didn't include any comments.
Aug 25 '06 #5
"McKirahan" <Ne**@McKirahan.comwrote in message
news:v8******************************@comcast.com. ..
"le0" <le*********@gmail.comwrote in message
news:uw**************@TK2MSFTNGP05.phx.gbl...

[snip]

It appears that your last post was incomplete;
that is, you didn't include any comments.
On re-re-re-reading it I finally found your buried comment:
'COMMENT: your condition here is always false

Did you try the code? It works for me.
Do While Not objRST.EOF
intNUM = intNUM + 1
strITM = strITM & "<br>" & objRST("ItemNo").Value
intITM = Int(objRST("ItemNo").Value)
If intNUM < intITM Then
For intNUM = intNUM To (intITM-1)
strNUM = strNUM & "<br>" & intNUM
Next
End If
intNUM = intITM
objRST.MoveNext
Loop
If 1 is found then intNUM=1 and intITM=1.
If 3 is the next number then intNUM=2 and intITM=3.
Thus, 2 < 3 and 2 will be identified as missing.
Aug 25 '06 #6

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

Similar topics

5
by: Annette Massie | last post by:
I have a park permit tracking database where I was thinking of having the user enter all the park permits individually, however realized that in a day, a park could host many daily users. So if 100...
9
by: Harsha Srinath | last post by:
Athough this might not be directly relayed to C syntax, I thought some of you may find this an interesting problem :- 1.One number, in an array integers from 1 to 1,000,000 is present twice. How...
17
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). ...
4
by: Mahesh BS | last post by:
Hello, I need to write a query to find out a set of missing number in a given sequence. Eg : a Column in some table has the following data
24
by: Kosmos | last post by:
Hey guys I'm a newbie and in fact I'm not even a programmer but decided to take up the task of learning access and creating a database. And I've gotten pretty far in terms of importing from excel and...
3
by: Fred Chateau | last post by:
Still working on my XML DataSet... Having moved on past difficult and complex problems, resolved with the assistance of everyone here, I find myself facing yet another problem. My XML document...
15
by: Mr.Tom.Willems | last post by:
Hello people, I am ussing an MS access database to enter and manage data from lab tests. until now i was the only one handeling the data so i had no need for a controle on how missing data was...
1
by: c8tz | last post by:
Hi, I have a palms table that stores palm census for each and every palm for a block on every trial. Every trial has a set number of blocks and set number of palms. Each of the palms has a palm...
2
kcdoell
by: kcdoell | last post by:
Hello: I am trying to create a union query but do not have a lot of experience. Basically I have the below tables: The Tables: Table Name = tblPrior CreditRegIDFK; Number; Foreign Key...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.