Dumb Visual BASIC question

I have a utility I support that’s written in Visual BASIC (6.0, if neccessary) that I’m trying to add a checkbox to. Well, the checkbox is in the dialog just fine, but I’m having trouble adding the supporting code to the appropriate source file.

Call the screen widget selectCheckbox. I try to manually add a subroutine called selectCheckbox() to the from source file, but I get a message saying an identical routine ‘already exists in an object module from which this object module derives’.

A search through the project for selectCheckbox turns up nothing. I cannot find a way to create a stub subroutine from either the graphic editor, or the properties page for the checkbox I added.

What am I doing wrong?

It may be that selectcheckbox is a reserved word - does it let you do it if you call it, say, SelectBanana?

I’ve tried several variations of the name, all with the same result. I also tried making the sub a differrent name than the checkbox itself, which failed rather spectacularly when I tried to compile.

I don’t understand that last bit - you had a checkbox with one name and a subroutine with another name, and this failed on compile?

That’s me, thinking in Visual C/C++, where I can create a widget and name the service routine pretty much what I want, within bounds of a few limitations. I have a problem at times working outside of my comfort zone.

The properties page for the widgets forces the routine to be named the same as the widget itself.

Found the answer to my problem. If I double click the widget while in the graphic edit mode, the sub is stubbed in the source code file AT THE TOP. I was trying to add it manually at the bottom.

:smack:

I’m still confused. In my experience, when you double-click a VB control to add code to it, it doesn’t create a function with the exact name of the control, but rather, with a combination of control name/event (e.g., CheckBox1_click). Is this VB6 you’re using?

It does - if you want to attach the code to a different event of the control, you just need to switch to the ‘events’ tab of the properties inspector and select the appropriate entry there - and it will create a subroutine stub.

But the naming of that subroutine - even though VB creates it based on the name of the control, to help you understand your code - is in fact arbitrary. The click event of checkbox1 need not point to a sub called checkbox1_click - it could be named anything (within the usual constraints, that is) - also, you can point more than one event at the same subroutine - again, but visiting the events property page for the control and selecting the subroutine against the appropriate event.