Label refresh problem in Vb 6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AKHTAR ALI
    New Member
    • Mar 2007
    • 7

    Label refresh problem in Vb 6.0

    Dear Sir,

    i am reading a text file line by line from vb and insert in oracle table through pl/sql procedure.
    in text file record is 70000, in my code i make a loop to read data in loop and insert in a oracle through pl/sql procedure.
    in a loop i make a counter in the starting of loop set counter value=1
    loop is run 70000 time becos data in text file is 70000.
    so i am display a label in the form the counter value display in label
    and refresh label every time..but after some time label refreshing is stop..but processing is going on...but i dont know how label refreshing is stop........plz help me...

    thanks
    Akhtar Ali
    akh_jhs@yahoo.c om
  • ansumansahu
    New Member
    • Mar 2007
    • 149

    #2
    Originally posted by AKHTAR ALI
    Dear Sir,

    i am reading a text file line by line from vb and insert in oracle table through pl/sql procedure.
    in text file record is 70000, in my code i make a loop to read data in loop and insert in a oracle through pl/sql procedure.
    in a loop i make a counter in the starting of loop set counter value=1
    loop is run 70000 time becos data in text file is 70000.
    so i am display a label in the form the counter value display in label
    and refresh label every time..but after some time label refreshing is stop..but processing is going on...but i dont know how label refreshing is stop........plz help me...

    thanks
    Akhtar Ali
    akh_jhs@yahoo.c om

    What is the datatype of the counter I that you are using in the loop.

    Just create a test form , place a lable and place this code in form_load
    //////////////////////////////////////////
    Dim i As Long
    For i = 1 To 70000
    Label1.Caption = i
    Next i
    //////////////////////////////////////////
    this should display the value 70000 on the label.

    This is what you want. Just display the counter value.

    thanks
    ansuman sahu

    Comment

    • AKHTAR ALI
      New Member
      • Mar 2007
      • 7

      #3
      Originally posted by ansumansahu
      What is the datatype of the counter I that you are using in the loop.

      Just create a test form , place a lable and place this code in form_load
      //////////////////////////////////////////
      Dim i As Long
      For i = 1 To 70000
      Label1.Caption = i
      Next i
      //////////////////////////////////////////
      this should display the value 70000 on the label.

      This is what you want. Just display the counter value.

      thanks
      ansuman sahu
      Dear Ansuman,

      i have done this activity no problem becos its not connected to oracle,but my problem is diffrent when i read data from text file in a loop read one line and insert in oracle table .
      each time read file line by line and insert in oracle ..i want to show counetr in my form using label how many line read from text file and insert in oracle...it works for some time ......but after some time cursor is busy and application is hang ....but proceesing is going on.....and in the screen counter is not increase.
      due to cursor busy.so i am not able to understand why application is hang and cursor is busy......

      Regards
      Akhtar

      Comment

      • devonknows
        New Member
        • Nov 2006
        • 137

        #4
        Originally posted by AKHTAR ALI
        Dear Ansuman,

        i have done this activity no problem becos its not connected to oracle,but my problem is diffrent when i read data from text file in a loop read one line and insert in oracle table .
        each time read file line by line and insert in oracle ..i want to show counetr in my form using label how many line read from text file and insert in oracle...it works for some time ......but after some time cursor is busy and application is hang ....but proceesing is going on.....and in the screen counter is not increase.
        due to cursor busy.so i am not able to understand why application is hang and cursor is busy......

        Regards
        Akhtar
        I know exactly what you mean, i find this with loops with most programming languages ive seen, once the loop goes on for so long and you are doing a few things each loop the app appears to go into a non responsive mode, but infact is still running the loop.

        I had the same problem (well similar) what i did was i made a timer to interval at 5 milliseconds, but create some private integers, for example

        Code:
        Private LineCount as Long
        Private Const MAX_LINES = 70000
        In your timer you could possibly put

        Code:
        if LineCount > MAX_LINES Timer1.Enabled = False
        get it to read the line, LineCount, and then once its done inserting into the db then set your label caption,

        Code:
        Label1.Caption = "Record " & LineCount & "/" & MAX_LINES
        LineCount = LineCount + 1
        then when your timer goes again it will work of the new LineCount number and Carry on till you hit MAX_LINES

        Im not to sure if this will help you, and not tested, but i thought it might give you a little nudge in the right direction. Hope this helps

        Kind Regards
        Devon.

        Comment

        • AKHTAR ALI
          New Member
          • Mar 2007
          • 7

          #5
          Originally posted by devonknows
          I know exactly what you mean, i find this with loops with most programming languages ive seen, once the loop goes on for so long and you are doing a few things each loop the app appears to go into a non responsive mode, but infact is still running the loop.

          I had the same problem (well similar) what i did was i made a timer to interval at 5 milliseconds, but create some private integers, for example

          Code:
          Private LineCount as Long
          Private Const MAX_LINES = 70000
          In your timer you could possibly put

          Code:
          if LineCount > MAX_LINES Timer1.Enabled = False
          get it to read the line, LineCount, and then once its done inserting into the db then set your label caption,

          Code:
          Label1.Caption = "Record " & LineCount & "/" & MAX_LINES
          LineCount = LineCount + 1
          then when your timer goes again it will work of the new LineCount number and Carry on till you hit MAX_LINES

          Im not to sure if this will help you, and not tested, but i thought it might give you a little nudge in the right direction. Hope this helps

          Kind Regards
          Devon.

          Dear Devon..

          i did ur process but it is again same problem

          plz any body can help me..

          Regards
          Akhtar

          Comment

          • vijaydiwakar
            Contributor
            • Feb 2007
            • 579

            #6
            Originally posted by AKHTAR ALI
            Dear Sir,

            i am reading a text file line by line from vb and insert in oracle table through pl/sql procedure.
            in text file record is 70000, in my code i make a loop to read data in loop and insert in a oracle through pl/sql procedure.
            in a loop i make a counter in the starting of loop set counter value=1
            loop is run 70000 time becos data in text file is 70000.
            so i am display a label in the form the counter value display in label
            and refresh label every time..but after some time label refreshing is stop..but processing is going on...but i dont know how label refreshing is stop........plz help me...

            thanks
            Akhtar Ali
            akh_jhs@yahoo.c om
            see refreshing is done by processor if ur processor is not geting time to refresh the lable then the label seems to be unfresh but actual process is going on
            to show the refreshing effect use doevents in ur for loop
            Try it
            Good Luck

            Comment

            • AKHTAR ALI
              New Member
              • Mar 2007
              • 7

              #7
              Originally posted by vijaydiwakar
              see refreshing is done by processor if ur processor is not geting time to refresh the lable then the label seems to be unfresh but actual process is going on
              to show the refreshing effect use doevents in ur for loop
              Try it
              Good Luck

              My Dear

              How to use doevent
              give me 1 example.

              regards
              Akhtar

              Comment

              • devonknows
                New Member
                • Nov 2006
                • 137

                #8
                Originally posted by AKHTAR ALI
                My Dear

                How to use doevent
                give me 1 example.

                regards
                Akhtar
                I believe that there maybe an easier way of making this happen, the doevent puts a lot of overhead code in but its designed to allow other parts of your program to be reactive, but as you your going up to 70000 i wouldnt have thought you need much reactivity out of it except possibly a cancel button...

                i believe that this might help you, by using the refresh method, the form and each control has a refresh method for example
                Code:
                lblstatus.Refresh
                
                or
                
                frmMain.Refresh
                however i believe something like this code below will be something you might be looking for, if this doesnt work then id suggest using doevents, but ive tested this just the label as ive got writers block and cant think for life what to test it with hehe.
                Code:
                Option Explicit
                Private lCount As Long
                Private Const MAX_LINES = 70000
                Private Sub Command1_Click()
                    Timer1.Enabled = True
                End Sub
                
                Private Sub Timer1_Timer()
                If lCount > MAX_LINES Then MsgBox "Process Finished": Timer1.Enabled = False
                    ' do something here
                    '
                    ' Update a label with iteration count
                    lblstatus.Caption = "Iteration #" & lCount
                    ' refresh *only* the label
                    lblstatus.Refresh
                    ' increase the count
                    lCount = lCount + 1
                End Sub
                Let me know how this goes,
                Kind Regards
                Devon.

                Reference to Refresh:
                DevX delivers the latest software development news, coding tutorials, and developer resources to help you build better applications.

                Comment

                • vijaydiwakar
                  Contributor
                  • Feb 2007
                  • 579

                  #9
                  See budies if the problem is
                  U like to show the processing liek its now reading line no 1
                  line no 2
                  line no 3

                  in such cases use doevent like
                  dim i&
                  for i=1 to 70000
                  lbl.caption=i
                  doevent
                  doevent
                  next
                  try it
                  Good Luck

                  Comment

                  • devonknows
                    New Member
                    • Nov 2006
                    • 137

                    #10
                    Just to quote the URL above that i post for the DevX site, it will explain why if you are just wanting to show what your program is doing, i.e. in a label to use refresh, doevents are to allow the rest of the program to have a bit of reactivity, were if you have changed the label and it hasnt updated, the simplest thing would be to refresh it, for example a web page, when something doesnt load properly, refresh it. But the link above will explain all. Never been a big fan of doevents to be persoanlly honest. Its rare that you actually see them being used to be honest, i cant recall ever using doevent to be honest.

                    But Try both see which works better for you and let us know, that way anyone this particular problem up over the search might be able to get it a bit more indepth and a better insight.

                    Kind Regards
                    Devon.

                    Comment

                    • SanjuMtr
                      New Member
                      • Mar 2007
                      • 47

                      #11
                      Hi Boss,
                      I Have already Entered 10 lacks Record From Vb App .
                      And Each Time Record Counter Is increase.
                      I suggest u to call DoEvent Within Loop.Its maintain The Event Queue.
                      Code:
                      Dim i as Long
                      i=0
                      While rs.EoF<>False
                      //insert record to table
                      i=i+1
                      lbl.Refresh
                      Doevents
                      lbl.caption="Total No of Records:" & i
                      lbl.refresh
                      rs.movenext
                      
                      Wend
                      Last edited by Killer42; Apr 1 '07, 02:07 AM. Reason: Please use [CODE]...[/CODE] tags around your code.

                      Comment

                      • Dököll
                        Recognized Expert Top Contributor
                        • Nov 2006
                        • 2379

                        #12
                        Originally posted by AKHTAR ALI
                        Dear Sir,

                        i am reading a text file line by line from vb and insert in oracle table through pl/sql procedure.
                        in text file record is 70000, in my code i make a loop to read data in loop and insert in a oracle through pl/sql procedure.
                        in a loop i make a counter in the starting of loop set counter value=1
                        loop is run 70000 time becos data in text file is 70000.
                        so i am display a label in the form the counter value display in label
                        and refresh label every time..but after some time label refreshing is stop..but processing is going on...but i dont know how label refreshing is stop........plz help me...

                        thanks
                        Akhtar Ali
                        akh_jhs@yahoo.c om
                        Greetings, AKHTAR ALI!

                        Would you like to post what you have working, just to give us an idea?

                        Looks like we may be spinning our wheels. Part of your code, at least, where you're stuck, may spring it into action. How 'bout that?

                        Dököll

                        Comment

                        • AKHTAR ALI
                          New Member
                          • Mar 2007
                          • 7

                          #13
                          Originally posted by SanjuMtr
                          Hi Boss,
                          I Have already Entered 10 lacks Record From Vb App .
                          And Each Time Record Counter Is increase.
                          I suggest u to call DoEvent Within Loop.Its maintain The Event Queue.
                          Code:
                          Dim i as Long
                          i=0
                          While rs.EoF<>False
                          //insert record to table
                          i=i+1
                          lbl.Refresh
                          Doevents
                          lbl.caption="Total No of Records:" & i
                          lbl.refresh
                          rs.movenext
                          
                          Wend
                          Hello my Dear

                          i am very glad to inform u .....my problem have been solved accordoing to ur code..thanks alots again...thanks alots all those people which is supported to me..

                          Regards
                          Akhtar
                          akh_jhs@yahoo.c om

                          Comment

                          • SanjuMtr
                            New Member
                            • Mar 2007
                            • 47

                            #14
                            Originally posted by AKHTAR ALI
                            Hello my Dear

                            i am very glad to inform u .....my problem have been solved accordoing to ur code..thanks alots again...thanks alots all those people which is supported to me..

                            Regards
                            Akhtar
                            akh_jhs@yahoo.c om
                            I am also happy to Help you
                            saikat Mitra

                            Comment

                            Working...