473,396 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Public properties and displaying them on a form - Help Needed.

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

Dec 7 '05 #1
2 1265
Hexman wrote:
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


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
Dec 7 '05 #2
On Wed, 07 Dec 2005 16:46:52 -0500, I Don't Like Spam <no@spam.com>
wrote:
Hexman wrote:
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

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. ChrBTW: 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


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
Dec 7 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
2
by: Greg Merideth | last post by:
Using Visual C# I created two forms such as namespace test { public class SystemTray : System.Windows.Forms.Form { public createwindow() { stuff here; } public fadewindow() { stuff to fade...
5
by: Boniek | last post by:
Hi I define a public property in a new form and I can see this property in table of Properties in Visual. How I can hide this property to see only in code ? Thank's Boniek
3
by: Joe Fromm | last post by:
Perhaps I'm missing something obvious, but I've been curious about one of the coding practices I see advocated. I'm a longtime C/C++ programmer trying to learn C#, and I started looking around for...
45
by: Brett | last post by:
If I do this without declaring a corresponding field, is it considered bad design? What are the advantages or disadvantages to either method? Notice there is not set. public string URL { get...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
9
by: Rudy | last post by:
Hello All! I'm a little confused on Public Class or Modules. Say I have a this on form "A" Public Sub Subtract() Dim Invoice As Decimal Dim Wage As Decimal Static PO As Decimal Invoice =...
11
by: dgk | last post by:
If I have a class with a public variable, isn't this the same as a private variable with a property? ie, isn't this: Public Class MyTest Public MyVar as String End Class the same as this: ...
1
by: Tom | last post by:
My unsigned DLL works in my project that references it as long as I set Copy Local = true. Now I have signed the DLL with the sn.exe generated keys but have not yet moved the DLL into the GAC. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.