Dear Friends.

Q:The problem in my coding is: I want to remove items from the string array if if does match with datareader field called time1 whose number in the Sql database is 4.

Would u pls tell me whats wrong with my coding .?
Its urgent..

With Regards,
Vinit.

Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged
    If myConnection.State = ConnectionState.Open Then

        myConnection.Close()
    End If
    myConnection.Open()

    If dr.IsClosed = True Then

        dr = myCommand.ExecuteReader()
    End If
    ListBox3.Items.Clear()
    Dim ar1() As String = {"0900:0930", "0930:1000", "1000:1030", "1030:1100", "1100:1130", "1130:0000", "1200:1230", "1230:1300", "1300:1330", "1330:1400", "1400:1430", "1430:1500", "1500:1530", "1530:1600", "1600:1630", "1630:1700"}
    TextBox1.Text = DateTimePicker2.Value
    DateTimePicker2.MinDate.ToString("dd/MM/yyyy")
    DateTimePicker2.MaxDate.ToString("dd/MM/yyyy")
    TextBox1.Text = (DateTimePicker2.Value.Date & " 0:00:00")

    Label2.Visible = True


    Label3.Visible = True
    ListBox3.Visible = True

    myCommand = New SqlCommand("Select * from appointment where ( date1 = CONVERT(DATETIME, '" & DateTimePicker2.Value.Date & "', 103))  ", myConnection)
    If dr.IsClosed = True Then

        dr = myCommand.ExecuteReader()
    End If


    Dim i As Integer
    If dr.HasRows() Then

        With dr
            .Read()

            Do While .HasRows

                For i = 0 To 14
                    If ((ar1(i).CompareTo(dr(4))) = True) Then
                ‘  I want to delete  listitems that are same      
                ‘ MsgBox(ar1(i))
                    Else
                     ‘remaining times in the list should appear on listbx.
                        ListBox3.Items.Add(ar1(i))
                    End If

                Next i
                .NextResult()
            Loop

        End With

        dr.Close()

    Else
        For i = 0 To 14

            ListBox3.Items.Add(ar1(i))

        Next i
    End If

End Sub
End Class
UTop = UBound(ItemArray)
ULower = LBound(ItemArray)

For lCtr As Integer = ItemElement To UTop - 1
    ItemArray(lCtr) = ItemArray(lCtr + 1)
Next

ReDim Preserve ItemArray(ULower To UTop - 1)
Be a part of the DaniWeb community

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