473,473 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

help me plz,this about arrays

5 New Member
use one dimensional arrays to solve the following problem .read in 20 number ,each of which is between 10 and 100 inclusive . as each number is input print it only if it is not a duplicate of number already input .provide for the worst case in which all 20 numbers are different,
i want this in VB6.plz help me .
i would be thanks for any help.
Aug 30 '08 #1
3 1323
rpicilli
77 New Member
Hello.

May be using a List of Integer is a better and clean solution.

Try this

CODE
Dim myNumber As New List(Of Integer)
Dim iTmp As Integer

Private Sub getNumber() 'Create your own way to get the number
iTmp = 0
iTmp = InputBox("Type a number: ", "Give a try")

If myNumber.Contains(iTmp) Then
'You already have this number
'Do what you need to do
MessageBox.Show("Number is already there. Try again.")
Else
'You do not have the number into you list
myNumber.Add(iTmp)
MessageBox.Show("Number included.")
End If
End Sub

Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
getNumber()
End Sub
Aug 31 '08 #2
rpicilli
77 New Member
Hello, just in case you realy want to use array...

CODE
Public Class Form1

Dim aMyArray(20) As Integer
Dim iTmp As Integer
Dim iNumItems As Integer
Dim bExist As Boolean = False

Private Sub getNumber() 'Create your own way to get the number
'Initialization
iTmp = 0
iNumItems = aMyArray.Length

iTmp = InputBox("Type a number: ", "Give a try")

For jTmp As Integer = 0 To iNumItems - 1
If aMyArray(jTmp) = iTmp Then
'You already have this number
'Do what you need to do
bExist = True
MessageBox.Show("Number is already there. Try again.")
Exit For
End If
bExist = False
Next

If Not bExist Then 'Adds the number to array
aMyArray(iTmp) = iTmp
End If

End Sub

Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
getNumber()
End Sub
End Class
Aug 31 '08 #3
doreme202002
5 New Member
thank for your help that was helpful ,so thanks very much
Sep 1 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Dariusz | last post by:
I want to use arrays in my website (flat file for a guestbook), but despite having read through countless online tutorials on the topic, I just can't get my code to work. I know there are...
4
by: CoolPint | last post by:
I would be grateful if someone could point out if I am understanding correctly and suggest ways to improve. Sorry for the long message and I hope you will kindly bear with it. I have to make it...
4
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled...
1
by: Geoff | last post by:
I was wondering if anyone could help me with a problem I am having. I am trying to read in a list of numbers from a file and then sort them using pointers and malloc() and free(). I know how to...
2
by: Pasacco | last post by:
dear I want to ask help on this problem. Array a is partitioned into a0 and a1 in main(). Then a1 is partitioned into a2 and a3 in th_partition() function. And I think this problem is something...
9
by: FERHAT AÇICI | last post by:
hi all! who know arrays on visual basic please tell me.... thanks..
9
by: weidongtom | last post by:
Hi, I've written the code that follows, and I use the function add_word(), it seems to work fine *before* increase_arrays() is called that uses realloc() to allocate more memory to words. But...
2
by: Dr Dav | last post by:
Hello all, I'm a physicist whose rewriting a numerical simulation, previously written in IDL, in C with the goal reducing runtime. As you may imagine, my C programming skills are quite poor but I...
5
by: saytri | last post by:
Hi i have this project were i have to do a quiz. i wrote the questions in a textfile and i called them through java. I have also made a menu to choose which type of quiz. But before accessing the...
110
by: fjm | last post by:
For some reason, I have always had a hard time understanding arrays as they pertain to php and databases. I understand associative arrays just fine but when there are multidimensional arrays, I kinda...
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
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...
0
Oralloy
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,...
1
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.