473,397 Members | 2,077 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,397 software developers and data experts.

Need help on a Project

I use Vb6.
I m looking for an easier way to make this program.
The program i need uses arrays and tries to get 5 different numbers. The purpose of this program is to loop through until the user puts in 5 distinct integers. The way i did it before is.

For instance,
I get the user to input the first number.
I get the user to input the second number, if it is the same as the first that it warns the user and ask it for the number again.
I keep doing this loop until i get all 5 numbers, the problem is that it takes a large size of code to do this. I wonder if there is an easier way to get the user to input 5 distinct numbers.

Ty.
Nov 1 '07 #1
6 1044
9815402440
180 100+
hi
this can be done with the help of ado recordset.

Expand|Select|Wrap|Line Numbers
  1. Dim rstNumber As New ADODB.Recordset
  2. rstNumber.Fields.Append "Number", adDouble
  3. rstNumber.Open
  4. Dim intNewNumber As Integer
  5. With rstNumber
  6.     Do While .RecordCount < 5
  7.         intNewNumber = Val(InputBox("Enter Number", "Title"))
  8.         If .RecordCount > 0 Then
  9.             .MoveFirst
  10.             .Find "Number = " & intNewNumber
  11.         End If
  12.         If Not .EOF Then
  13.             MsgBox "This number already exists."
  14.         Else
  15.             .AddNew
  16.             .Fields("Number").Value = intNewNumber
  17.         End If
  18.     Loop
  19. End With
regards
manpreet singh dhillon hoshiarpur
Nov 2 '07 #2
Killer42
8,435 Expert 8TB
Why would you go to all the trouble of setting up a database for this?
Nov 2 '07 #3
I dont know how to set up a database :/
Nov 2 '07 #4
debasisdas
8,127 Expert 4TB
I dont know how to set up a database :/
No need to go for database connection for this at all.
Nov 2 '07 #5
daveftl
43
Have it this way:


Have an array with index from 0 to 4.
Then every time the user inputs a number it will loop through the array and
check if there exists the same number:

Expand|Select|Wrap|Line Numbers
  1. Dim myArray(0 To 4)
  2. set myArray(i%)
  3. For i  = 0 To 4
  4.   ' Your code here for checking if it's a unique number.
  5.   ' If it's unique then insert it in the array.
  6. Next
Hope this will help.
Nov 3 '07 #6
QVeen72
1,445 Expert 1GB
I use Vb6.
I wonder if there is an easier way to get the user to input 5 distinct numbers.
Ty.
Hi,

Why don't you simply place 5 textboxes on the form, maybe in a control array?

Write distinct checking in a command button, by looping through the control array. Or write the code in textbox's Validate/LostFocus event.

Regards
Veena
Nov 3 '07 #7

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

Similar topics

11
by: Mark | last post by:
Hi, For the last 2 years I've been developing vehicle tracking/telemetric software for a company as a self employed individual. The project is quiet big, and is going to be there flagship...
3
by: Andrej Hristoliubov | last post by:
I am the best c++ programmer in the whole wide world. Trust ME! My reference is Victor Bazarov,Valentin Samko,Alf P.Steinbach( Me and Alf actually intern together at Microsoft), and Bjarne...
10
by: Tom | last post by:
I am looking for some ideas for how to design the layout of the form for data entry and to display the data for the following situation: There are many sales associates. A sales associate can work...
48
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
6
by: sivashankar | last post by:
hello experts -can any one give me some module to do in asp.net -if u give me the description i will give u with free of cost,since am new now am in my final semester of MCA,just give me some...
7
by: moondaddy | last post by:
I want to create a public enum that can be used throughout a project. I created an enum like this in a module: Public Enum ParentType Project = 0 Stage = 1 VIP = 2 Func = 3 Equipment = 4...
5
by: info | last post by:
Hi! Please be patient with a newbie... I use DevC++. I've found and compiled succefully various openGL examples. Before build the application, I link the project with static libs, like, in...
8
by: Brett Romero | last post by:
I have this situation: myEXE <needs< DerivedClass <which needs< BaseClass Meaning, myEXE is using a type defined in DerivedClass, which inherits from BaseClass. I include a reference to...
0
by: garimaarora | last post by:
hi i am a beginner of c++ language and had tried to build a project in c++ language the project is throwing me set of exceptions and i need ur help if there is anybody who is interested in...
10
by: Frank | last post by:
I've done this a few times. In a solution I have a project, Say P1, and need another project that will contain much code that is similar to that of P1. I hope no one gets hung up on why I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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:
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,...
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,...
0
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...

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.