xiiopao 0 Newbie Poster

anyone here knows how to delete or hide an array element in asp permanently or until the application? im currently developing an application wherein once an array element matches the typed text in the textbox it should be removed from the list. what my code does is it deletes the last element and returns it when a new word is typed which is wrong. Im a newbie in asp by the way , here's my code

 <%  Dim item
                Dim words(3)
                words(0) = "hello"
                words(1) = "again"
                words(2) = "world"
                words(3) = "display"

                Dim i
                For i=LBound(words) to UBound(words) 
                Response.Write words(i) & "<br>"

                Function in_array(element, arr)
                    For i=0 to Ubound(arr)
                        If Trim (arr(i)) = Trim(element) Then
                        in_array = true 
                        Exit Function

                            in_array = false
                        End if 
                End Function

                str= Request.QueryString("searchWord")

                if in_array(str,words) Then

                delete words, 0

                    Response.Write words(ubound(words)-1)
                End If

                Sub delete(ByRef ar, ByVal idx)
                    Dim i
                    Dim ub

                    ub = UBound(ar) - 1

                    For i = idx To ub
                        ar(i) = ar(i + 1)
                    ReDim Preserve my_words(ub)
                End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.