TextBox.update - problem

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

For i = 1 to 5000
Me.txtCounter.text = i
'As I found the textbox didn't update itself, I add
(Me.txtCounter.update)
'.... some calculation statment
end for

Me.txtcounter.update sometimes work , sometimes doesn't ,
I saw the textbox show "289" and then stop , but the statment runs very
well.
Does anymethod to push the textbox must show the correct value,
Thanks
 
Agnes,

You don't have option strict on.

I advice you to do that in every program.

At least you would see that this is better as

For i = 1 to 5000
Me.txtCounter.text = i.ToString
'As I found the textbox didn't update itself, I add
(Me.txtCounter.update)
'.... some calculation statment
end for

However it will not be showed, for that you need a txtCounter.show or an
application.doevents in it, which slows up the procedure because it has to
be painted. Therefore if you do it, do it than in amount the user can see
(by instance test if the mod divide by 10 = 0)

I hope this helps,

Cor
 
Agnes said:
For i = 1 to 5000
Me.txtCounter.text = i
'As I found the textbox didn't update itself, I add
(Me.txtCounter.update)
'.... some calculation statment
end for

Me.txtcounter.update sometimes work , sometimes doesn't ,
I saw the textbox show "289" and then stop , but the statment runs very
well.
Does anymethod to push the textbox must show the correct value,


Your code should work, it works for me when changing the 'End For' to 'Next
i'.
 
YES. i didn't set it..
Where Should I set it ??
in fact.. What does it mean 'option strict on ' ??
 
Agnes said:
YES. i didn't set it..
Where Should I set it ??
in fact.. What does it mean 'option strict on ' ??

Open the documentation and read the chapter about 'Option Strict'. You can
set it on top of each source file or in the project properties for the whole
project.
 
Agnes,

You can set on every program file in Top
Option Strict On
Or you can set it in the general options, in your case I would start with
setting it on every page.

The why is say it simple.

If you have it off, than the computer searches at runtime the best format
(type) to use (late binding).
With option strict on you have to do that yourself direct.

The advantage is that there are no wrong types taken at runtime.
(And because of the fact that it has not to be searched for, goes faster)

I hope that this gives an idea

Cor
 
Force the textbox to redraw itself, as in

For i As integer = 1 to 5000
Me.txtCounter.Text = i.ToString()
Me.txtCounter.Refresh()

'.... some calculation statment
Next

(Or, better still, put the call to Refresh into the TextBox's
Changed Event Handler).

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top