Well, back for another question.
I'm doing some calculations in a module (the reason in a module is
because it is an I-O module - reading csv files, Access DB, etc.). (If
not in a Module, where should I put them.) From 'form1' I perform a
sub located in the module. As I read files and calculate, I want to
display the statistics of the records read and their calculations. I
posted a similar question a few days ago and was told to use
properties. I searched for examples and here's what I have set up as
a test.
In form1:
Public Property kkk() As String
Get
kkk = lblCntRecs.text
End Get
Set(ByVal Value As String)
lblCntRecs.Text = Value
End Set
End Property
In the Module:
Module Module1
Dim myform As New Form1
Public Sub testit()
Dim x As Long
For x = 0 To 9000000
If x Mod 1000 = 0 Then
myform.kkk = x.ToString("###,##0")
End If
Next
End Sub
End Module
The sub completes, but the label does not change during execution.
Only when the sub completes does the label change to the last value of
x.
What do I need to do to make the interim calcs/results appear on form1
during execution of the sub?
Hexman
I Don't Like Spam - 07 Dec 2005 21:46 GMT
> Well, back for another question.
>
[quoted text clipped - 38 lines]
>
> Hexman
Dim myform As New Form1
Here you create a new form1, not the one you are calling from.
To do it this way you need a setup like:
Public Sub testit(myform as Form1)
And when you call testit from form1 you call it like:
testit(me)
A better way to do it would be to have a callback function that you pass
into testit. BTW: you won't get to see your processing because the
calcuation will eat up all the processor and you won't get a redraw. I
think will fix it:
Set(ByVal Value As String)
lblCntRecs.Text = Value
Me.Refresh
End Set
If not then try Application.Doevents instead.
Chris
Hexman - 07 Dec 2005 23:50 GMT
>> Well, back for another question.
>>
[quoted text clipped - 60 lines]
>
>Chris
Chris,
Thanks alot. Its now working by brute force. The Me.Refresh did it.
>A better way to do it would be to have a callback function that you pass
>into testit.
Can you either explain to me or point me in the direction to find out
what/how a callback function would work.
Thanks again