By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,360 Members | 2,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,360 IT Pros & Developers. It's quick & easy.

Label refresh problem in Vb 6.0

P: 7
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.com
Mar 21 '07 #1
Share this Question
Share on Google+
13 Replies


100+
P: 149
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.com

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
Mar 21 '07 #2

P: 7
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
Mar 21 '07 #3

devonknows
100+
P: 137
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

Expand|Select|Wrap|Line Numbers
  1. Private LineCount as Long
  2. Private Const MAX_LINES = 70000
  3.  
In your timer you could possibly put

Expand|Select|Wrap|Line Numbers
  1. if LineCount > MAX_LINES Timer1.Enabled = False
  2.  
get it to read the line, LineCount, and then once its done inserting into the db then set your label caption,

Expand|Select|Wrap|Line Numbers
  1. Label1.Caption = "Record " & LineCount & "/" & MAX_LINES
  2. LineCount = LineCount + 1
  3.  
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.
Mar 21 '07 #4

P: 7
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

Expand|Select|Wrap|Line Numbers
  1. Private LineCount as Long
  2. Private Const MAX_LINES = 70000
  3.  
In your timer you could possibly put

Expand|Select|Wrap|Line Numbers
  1. if LineCount > MAX_LINES Timer1.Enabled = False
  2.  
get it to read the line, LineCount, and then once its done inserting into the db then set your label caption,

Expand|Select|Wrap|Line Numbers
  1. Label1.Caption = "Record " & LineCount & "/" & MAX_LINES
  2. LineCount = LineCount + 1
  3.  
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
Mar 29 '07 #5

vijaydiwakar
100+
P: 579
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.com
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
Mar 29 '07 #6

P: 7
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
Mar 30 '07 #7

devonknows
100+
P: 137
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
Expand|Select|Wrap|Line Numbers
  1. lblstatus.Refresh
  2.  
  3. or
  4.  
  5. frmMain.Refresh
  6.  
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.
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private lCount As Long
  3. Private Const MAX_LINES = 70000
  4. Private Sub Command1_Click()
  5.     Timer1.Enabled = True
  6. End Sub
  7.  
  8. Private Sub Timer1_Timer()
  9. If lCount > MAX_LINES Then MsgBox "Process Finished": Timer1.Enabled = False
  10.     ' do something here
  11.     '
  12.     ' Update a label with iteration count
  13.     lblstatus.Caption = "Iteration #" & lCount
  14.     ' refresh *only* the label
  15.     lblstatus.Refresh
  16.     ' increase the count
  17.     lCount = lCount + 1
  18. End Sub
  19.  
Let me know how this goes,
Kind Regards
Devon.

Reference to Refresh:
http://www.devx.com/vb2themax/Tip/18646
Mar 30 '07 #8

vijaydiwakar
100+
P: 579
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
Mar 30 '07 #9

devonknows
100+
P: 137
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.
Mar 30 '07 #10

P: 47
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.
Expand|Select|Wrap|Line Numbers
  1. Dim i as Long
  2. i=0
  3. While rs.EoF<>False
  4. //insert record to table
  5. i=i+1
  6. lbl.Refresh
  7. Doevents
  8. lbl.caption="Total No of Records:" & i
  9. lbl.refresh
  10. rs.movenext
  11.  
  12. Wend
Mar 31 '07 #11

Dököll
Expert 100+
P: 2,364
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.com
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
Mar 31 '07 #12

P: 7
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.
Expand|Select|Wrap|Line Numbers
  1. Dim i as Long
  2. i=0
  3. While rs.EoF<>False
  4. //insert record to table
  5. i=i+1
  6. lbl.Refresh
  7. Doevents
  8. lbl.caption="Total No of Records:" & i
  9. lbl.refresh
  10. rs.movenext
  11.  
  12. 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.com
Apr 3 '07 #13

P: 47
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.com
I am also happy to Help you
saikat Mitra
Apr 13 '07 #14

Post your reply

Sign in to post your reply or Sign up for a free account.