|
-
Nov 8th, 2006, 03:38 PM
#1
Thread Starter
New Member
Help with User Supplied Number Array
Hello everyone,
If anyone has some time to answer a question I have, I'm working on a problem for school and I thought I had this answered, but it just gives me errors. This is a console app that will ask a user to type 20 numbers between 10 and 100. The program reads the number making sure its between 10 and 100 and then checks to see if its a duplicate. If its not a duplicate it will be added to the array. Can anyone tell me what I've done wrong? Here is the code I have so far.Thank you for any help in advance.
Private Duplicate As Boolean = False
Sub Main()
Dim intNumberArray As Integer() = New Integer(19) {}
Dim index As Integer = 0
Dim intCount As Int16 = 0
Dim intNewNum As Integer
Do While intNumberArray(index) < 20
Console.WriteLine("Please enter a number from 10 to 100")
intNewNum = Val(Console.ReadLine)
Select Case intNewNum
Case 10 To 100
For index = 0 To intNumberArray.GetUpperBound(0)
If intNewNum = intNumberArray(index) Then ' its a duplicate
Duplicate = True
Console.Writeline("This is a duplicate, please try again.")
ElseIf Duplicate = False Then
intNewNum += intNumberArray(index)
End If
Next
Case Else
Console.WriteLine("That number is not from 10 to 100, please enter a _ correct value")
End Select
Loop
Console.Write("The numbers are: ")
Console.Write(intArray(index) & " ")
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|