the program runs, and user is prompted via inputbox to enter an integer-this is the size of the array, then the user fills the array with that many values...but as the user enters the values, i need to check and make sure that none of hte values have already been entered in the array, if it has..then there must be a message telling user to enter a new value.
EX: user prompted to enter an integer e.g.-2, then user is prompted to enter values to fill array, it loops until 2 values have been entered- e.g. 1 and 2..then the numbers 1 and 2 are displayed in a list box...but if the user enters 1 and 1..there needs to be a message or input box saying to enter a new value b/c 1 has already been used.
any help on searching the array would be great, here is my code:
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim length As String
length = InputBox("Enter size of array")
Do While Not ispositiveinteg er(length)
length = InputBox("Enter size of array")
Loop
Dim stringarray() As String
stringarray = MakeArray(lengt h)
Dim i As Integer
For i = 0 To stringarray.Get UpperBound(0)
lstdisplay.Item s.Add(stringarr ay(i))
End If
Next
End Sub
Function MakeArray(ByVal size As Integer) As String()
Dim Array(size - 1) As String
Dim i As Integer
For i = 0 To Array.GetUpperB ound(0)
Array(i) = InputBox("Enter array values: ")
Next
Return Array
End Function
End Class
EX: user prompted to enter an integer e.g.-2, then user is prompted to enter values to fill array, it loops until 2 values have been entered- e.g. 1 and 2..then the numbers 1 and 2 are displayed in a list box...but if the user enters 1 and 1..there needs to be a message or input box saying to enter a new value b/c 1 has already been used.
any help on searching the array would be great, here is my code:
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load
Dim length As String
length = InputBox("Enter size of array")
Do While Not ispositiveinteg er(length)
length = InputBox("Enter size of array")
Loop
Dim stringarray() As String
stringarray = MakeArray(lengt h)
Dim i As Integer
For i = 0 To stringarray.Get UpperBound(0)
lstdisplay.Item s.Add(stringarr ay(i))
End If
Next
End Sub
Function MakeArray(ByVal size As Integer) As String()
Dim Array(size - 1) As String
Dim i As Integer
For i = 0 To Array.GetUpperB ound(0)
Array(i) = InputBox("Enter array values: ")
Next
Return Array
End Function
End Class
Comment