Lennie Kuah

Lennie Kuah

  • NA
  • 27
  • 0

VBNET2008 Within FOR LOOP fill TextBox and ProgressBar

Feb 22 2012 1:55 AM
Hullo Good Friends,
I do need your help. Please help me.

I was instructed by Business Analyst to developer a application Within the FOR LOOP LOGIC to fill the ORDERID and Table Row Number on the TEXTBOX on the  FORM and also to display PROGRESSBAR of the progress within FOR LOOP

To my surprise the TEXTBOX and PROGRESSBAR1 is not working within the FOR LOOP LOGIC.

Here are the over all coding.

Private Sub FCountTotalOrderID()
        '--- retrieve OrderID Row count from Table ---
        Dim strsql As String
        strsql = " Select count(OrderID) as [intTotalOrderID]"
        strsql &= " From TblOrders "
        strsql &= " Where (CustomerID = N'" & strCustID & "')"

            sqlconn = New SqlConnection(connstr)
            sqlcmd = New SqlCommand(strsql, sqlconn)
            sqlcmd.Connection.Open()

            DR = sqlcmd.ExecuteReader

            If DR.HasRows = True Then
                While DR.Read()
                    intTotalOrderID = DR.GetValue(0)
                    Me.txtTotalOrderID.Text = DR.GetValue(0).ToString
                End While
            End If

            sqlconn.Close()
            DR.Dispose()
     End Sub

    '--- Using FOR LOOP TO FILL TEXTBOX ON FORM AND DISPLAY PROGRESSBAR ---

Private Sub BtnForLoopAction_Click(ByVal sender As System.Object,
        ByVal e As System.EventArgs) Handles BtnForLoopAction.Click
 

        Dim intI As Integer = 0
        Dim intX As Integer = 0    
        Dim strOrdID As String
        Dim strRowNum As String
        Dim strsql As String

        strsql = "Select OrderID from TblOrders "
        strsql &= " Where (CustomerID = N'" & strCustID & "')"
        strsql &= " Order by OrderID "

           sqlconn = New SqlConnection(connstr)
            sqlconn.Open()
            DA = New SqlDataAdapter(strsql, sqlconn)
            DS = New System.Data.DataSet
            DA.Fill(DS, "Order")

            Me.ProgressBar1.Maximum = intTotalOrderID
            Me.ProgressBar1.Minimum = 0
            Me.ProgressBar1.Value = 0
 
     For intI = 1 To intTotalOrderID Step 1

          '--- Display Progress Bar ---
          If Me.ProgressBar1.Maximum <> intI Then
                Me.ProgressBar1.Value = intI
          End If

           '--- Fill Form TextBox ---
          Me.TextOrderID.Text = DS.Tables("Order").Rows(intI)("OrderID").ToString
          Me.TextRow.Text = intI.ToString

    Next intI

End Sub

THANK YOU VERY MUCH FOR HELPING ME
CHEERS,
LENNIE