Wrapping controls WithEvents in classes (1 Viewer)

Page 29
You specify
Code:
Private colCtls As Collection
and then
Code:
Private Sub Class_Initialize()
Set colCtls = New Collection
End Sub
Private Sub Class_Terminate()
Set colCtls = Nothing
End Sub

but then use
Code:
Case acComboBox
Dim lclsCtlCbo As clsCtlCbo
Set lclsCtlCbo = New clsCtlCbo
lclsCtlCbo.mInit ctl
mcolCtls.Add lclsCtlCbo, ctl.Name
so the compile balked at mcolCtls

Changing them all to mcolCtls allows a compile? So which should it be please?

Edit:
You specify this on 37
Code:
Private Sub mctlCbo_GotFocus()
mctlCbo.BackColor = cBackColorFocus
End Sub
but have not defined cBackColorFocus
 
Last edited:
Apologies but I have to take my daughter Allie to school, then I have to pick up the ex and bring her home from a recovery place (knee replacement). I will be back available probably this afternoon.
 
Page 29
You specify
Code:
Private colCtls As Collection
and then
Code:
Private Sub Class_Initialize()
Set colCtls = New Collection
End Sub
Private Sub Class_Terminate()
Set colCtls = Nothing
End Sub

but then use
Code:
Case acComboBox
Dim lclsCtlCbo As clsCtlCbo
Set lclsCtlCbo = New clsCtlCbo
lclsCtlCbo.mInit ctl
mcolCtls.Add lclsCtlCbo, ctl.Name
so the compile balked at mcolCtls

Changing them all to mcolCtls allows a compile? So which should it be please?

Edit:
You specify this on 37
Code:
Private Sub mctlCbo_GotFocus()
mctlCbo.BackColor = cBackColorFocus
End Sub
but have not defined cBackColorFocus
It should be mColCtls. Do as I say not as I do. My naming conventions wants to use mColCtls, with the m meaning module level variable (in a class) or fColCtls with the f meaning Form level in a form's class.

Sorry for the confusion. I have fixed it in the book although TBH I am not even finding where I dim the mColCtls in the explanation in the book.

One of the issues I have to deal with is that as I do things in the book, stuff moves around. Pages shift and so forth.

I think I have found and fixed it in the book. I found it long ago in the database because it wouldn't compile like that.
 
You define colCtls on page 29 and mColCtls on page 171
Use the Find option in your pdf viewer. Mine is Foxit Reader.
 
You define colCtls on page 29 and mColCtls on page 171
Use the Find option in your pdf viewer. Mine is Foxit Reader.
LOL, right you are. I have searched for colCtls, found and fixed every one without the m in front.

I do appreciate your patience.

The updated version is on Github for download. Again, I am not able to post links yet so there is that.
 
Apart from the unnecessary use of Win64, I'm surprised if it worked when the output was wrongly defined as LongPtr.
And this is the problem. I don't have the x64 version. In fact all I have is the permanent version. I don't use the subscription model. It compiles, I know that.
 
BTW there is another version which will come up later in the book which uses fast timing, down to microseconds. More of the api calls.

A few years ago, I wrote a lengthy article about 6 different methods for measuring time intervals including a high resolution timer capable of measuring to 0.1 microsecond precision. Unfortunately, its accuracy is less than many other methods.

For full details, see my article which includes an example app with detailed tests and all relevant code / API calls.

 
And this is the problem. I don't have the x64 version. In fact all I have is the permanent version. I don't use the subscription model. It compiles, I know that.

API declarations will compile in 64-bit if they include PtrSafe.
However, that doesn't mean that they will work correctly in that bitness. Thorough testing is essential

To the best of my knowledge, all Office licenses from at least 2010 onwards allow users to install Office on at least two workstations (or VMs). If you obtained Office 2010+ on CD/DVD , that will include both bitnesses. Download versions allow you to choose as well. Suggest you install the 64-bit version on a VM.
 
And this is the problem. I don't have the x64 version. In fact all I have is the permanent version. I don't use the subscription model. It compiles, I know that.
John,
Do you want this to keep going here or take it privately?
Page 45. In the header of clsFrm ass the following line of code:
Also in ClsCtlRecSelSimple you have mclngBackColor yet use clngBackColor elsewhere. In fact mclngBackColor is not used anywhere.

You also state
'Dimension a text box Withevents
Private mtxtRecPK As TextBox 'The text box bound to the RECID

No WithEvents? why can't we use the clsTxt textbox?
 
Last edited:
API declarations will compile in 64-bit if they include PtrSafe.
However, that doesn't mean that they will work correctly in that bitness. Thorough testing is essential

To the best of my knowledge, all Office licenses from at least 2010 onwards allow users to install Office on at least two workstations (or VMs). If you obtained Office 2010+ on CD/DVD , that will include both bitnesses. Download versions allow you to choose as well. Suggest you install the 64-bit version on a VM.
well... yea. I am retired in a manner of speaking.
 
I'll get there one day...
TBH, I am bored out of my head. I gave up volunteering with the Community Car Scheme as Wales made most of the roads I would use a 20mph speed limit. That was driving me around the bend (no pun intended). Hell, even going to the shops once a fortnight is annoying.
So be careful, unless you know you will have a busy retirement life. :)
 
@jwcolby54 are you able to put anchors on your blog?, so one can go straight to a place in the blog, instead of having to scroll through everything?

Edit: Never mind, this view allows for that.
 
Last edited:
OK so... the m prefix fixed in both the document and database. I have to keep them in sync...

Both pushed to GitHub.

You mentioned anchors... no idea what you are talking about specifically however in the PDF on my machine, there is a sidebar on the right hand side with all of the heading widgets visible and you can just click on them to go to that thing in the pdf. That works pretty well if you remember where you were previously.

I am still trying to figure out how to create a private repository so I can do this stuff with the LibreWriter document file for the book. Of course then I will likely have to deal with which one I see in the GitHub desktop.
 

Users who are viewing this thread

Back
Top Bottom