473,837 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2448
"le0" <le*********@gm ail.comwrote in message
news:#2******** ******@TK2MSFTN GP02.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*********@gm ail.comwrote in message
news:#2******** ******@TK2MSFTN GP02.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="VBSc ript" %>
<% Option Explicit
'*
'* Declare Constants
'*
Const cASP = "ItemNo.asp "
Const cMDB = "ItemNo.mdb "
Const cDSN = "Provider=Micro soft.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.CreateOb ject("ADODB.Con nection")
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("Ite mNo").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*********@gm ail.comwrote in message
news:#2******* *******@TK2MSFT NGP02.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="VBSc ript" %>
<% Option Explicit
'*
'* Declare Constants
'*
Const cASP = "ItemNo.asp "
Const cMDB = "ItemNo.mdb "
Const cDSN = "Provider=Micro soft.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.CreateOb ject("ADODB.Con nection")
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("Ite mNo").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*********@gm ail.comwrote in message
news:uw******** ******@TK2MSFTN GP05.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*********@gm ail.comwrote in message
news:uw******** ******@TK2MSFTN GP05.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("Ite mNo").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
1797
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 daily permits were issued, the data entry would consist of 100 entries with only the permit number changing. If I changed the database to collect beginning and ending permit number would I be able to find the missing permit numbers? Say an...
9
11690
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 can you determine which one? Can you think of a way to do it using little extra memory? 2. How would you find the only missing element in that array? Can you think of a way to do it while iterating through the array only once. Is overflow a...
17
3040
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). I have a dataset as follows (1 week to keep it short): Employee 1 - Date 1 Employee 1 - Date 2
4
25514
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
2678
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 taking serial numbers such as AXT209939300LT and just stripping them down to the number of 209939300 for example. So here's where I am confused...and I've asked this question a couple of times but I've given it more thought and I think this is the...
3
2835
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 breaks the schema. There are missing tags everywhere, on purpose I'm told, because we don't need them. I'm getting a "System.Data: There is no row at position <row number>" error. Hopefully I can workaround this issue. I need to find a way to...
15
12208
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 entered, since i did it myself i knew exactly what data was missing... The problem is that i can have data that hasn't been enterd yet, or data that is below detection level(so missing).
1
1632
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 census done every year to check its status. The problem firstly is that for data entry: Entry is done such that the trial, plot is entered, and also palm number and the status. Sometimes not all the palms are being entered, so there are a few
2
4952
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 for the Credit Region ID
0
9827
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10560
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10609
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10263
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6987
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5663
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5838
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4468
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4034
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.