In my Visual Basic program I'm just trying to find duplicate values entered into an array from an inputbox, but i can't seem to get the coding right on the final part to check for duplicate values already entered. Any help would be greatly appreciated. This is what i have so far except the code to check for duplicate values: - Dim intarray() As Integer
-
Dim intindex As Integer
-
Dim intcount As Integer
-
Dim intsearch As Integer
-
Dim intlow As Integer, inthigh As Integer
-
intlow = -32676
-
inthigh = 32676
-
ReDim intarray(intlow To inthigh)
-
-
For intindex = LBound(intarray) To UBound(intarray)
-
Do
-
intnumber = InputBox("Enter a number:", "Enter number")
-
If intnumber < 1 Or intnumber > 99 Then
-
MsgBox "Please enter numbers only between 1 and 99"
-
End If
-
intarray(intindex) = intnumber
-
intcount = intcount + 1
-
lstnums.AddItem intnumber
-
Loop Until 'duplicate is found
-
Next intindex
-
lbldisplay.Caption = "Duplicate number after " & intcount & " times."
-
-
End Sub
2 2571
In my Visual Basic program I'm just trying to find duplicate values entered into an array from an inputbox, but i can't seem to get the coding right on the final part to check for duplicate values already entered. Any help would be greatly appreciated.
what about doing a bubble / shell sort then running throught the values comparing them to the next one in the array, the only problem would be if you did not want the values sorted
here is a link for shell sort which can be ammended to sort text instead of numbers although for some reason it only seems to work once the array is at least 5 long http://www.dreamincode.net/code/snippet857.htm
The sort seems a bit over the top, since it will have to comapre all the values at least once anyway.
Just do a nested loop. For example... - Dim I As Long, J As Long
-
For I = 1 To SizeOfArray - 1
-
For J = I + 1 To SizeOfArray
-
If Array(I) = Array(J) Then
-
DuplicateFlag = True
-
Exit For
-
End If
-
Next
-
If DuplicateFlag Then Exit For
-
Next
-
This is just off the top of my head, don't take it as Gospel. :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: lawrence |
last post by:
Dear Peter,
Do we know anyone else who writes PHP code? There is too much work to
do, especially if Costin and I are going to join our software
together.
The easiest way for us to join our software together is through high
level wrapper classes that take other classes for arguments. Costin
and I could move toward joining the software one package at a time.
|
by: JaNE |
last post by:
Hello, I have made my cms... and is working, but have some, let me say
"bugs"... And I don't know all reasons, please allow me slightly longer
and most probably confusing post (that "confusing" is mainly becaose of
my bad english, and that bad english is also reason why am I learning
php that slow...).
As first, what is problem:
some users after succsesfull registration and login can not see
"memeber_menu" and can not activly participate...
|
by: Psykarrd |
last post by:
I am trying to declare a string variable as an array of char's. the
code looks like this.
char name;
then when i try to use the variable it dosn't work, however i am not
sure you can use it the way i am trying to. Could some one please tell
me what i am doing wrong, or another way of doing the same thing. i am
trying to use the variable like this.
|
by: James Fortune |
last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't
understand why people who know how to write code to completely replace
a front end do not write something that will automate the code that
implements managing unbound controls on forms given the superior
performance of unbound controls in a client/server environment. I can
easily understand a newbie using bound controls or someone with a
tight deadline. I guess I need...
|
by: mark |
last post by:
Hello-
i am trying to make the function addbitwise more efficient. the code
below takes an array of binary numbers (of size 5) and performs
bitwise addition. it looks ugly and it is not elegant but it appears
to work. using time, i measured it takes .041s to execute, which i
admit isnt much. but, the problem is that this procedure will be
called many, many times in my project (probably at least a few
thousand times, if not more) so...
| |
by: amerar |
last post by:
Hi All,
Here is my situation: I have a form where the user can perform a
number of tasks. One of these tasks is to enter a new record. The
form has an 'onsubmit' property to validate the data if the users
enters a new record.
However, there is also a button to allow the user to 'duplicate' a
stored record. In that case, I do not want to perform the entire
validation since most of the data will be fetched from the database
|
by: Cheryl Langdon |
last post by:
Hello everyone,
This is my first attempt at getting help in this manner. Please
forgive me if this is an inappropriate request.
I suddenly find myself in urgent need of instruction on how to
communicate with a MySQL database table on a web server, from inside
of my company's Access-VBA application. I know VBA pretty well but
have never before needed to do this HTTP/XML/MySQL type functions.
|
by: Johan Tibell |
last post by:
I would be grateful if someone had a minute or two to review my hash
table implementation. It's not yet commented but hopefully it's short
and idiomatic enough to be readable. Some of the code (i.e. the
get_hash function) is borrowed from various snippets I found on the
net. Thee free function could probably need some love. I have been
thinking about having a second linked list of all entries so that the
cost of freeing is in proportion to...
|
by: U S Contractors Offering Service A Non-profit |
last post by:
Brilliant technology helping those most in need Inbox
Reply
U S Contractors Offering Service A Non-profit
show details
10:37 pm (1 hour ago)
Brilliant technology helping those most in need Inbox
Reply
from Craig Somerford <uscos@2barter.net>
hide details 10:25 pm
(3 minutes ago)
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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();...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |