Prev: Pictures
Next: .tlb crash
From: Jeff Caton on
Hello!

All my project share some "common" modules where I have anything that I
use in all projects.

In one of this modules I have a function that translates captions and texts.

I am using control from TimoSoft-software.de, and unfortunately he named
his controls just like the VB6 controls.

So when I say something like

for each c in form.controls
if typename(c) = "CommandButton" then
c.caption = ...

it will fail, because Timos controls use ".Text", not ".Caption".

I am now trying to find out what kind of control I am dealing with.
Therefore I am using

If TypeOf(c) Is BtnLibCtlU.CommandButton
(...)

This works fine, but some of my projects don't reference this control,
and I cannot compile. Making #IF statements (to see which project I am
dealing with) looks like an overkill to me.

What should I do? Should I simply reference the control, and don't care
if it is not there at runtime? Could this throw an error under some
strange circumstances?
From: Jeff Caton on
ps:

I used On Error Resume Next which caused a crash (GPF) on one computer,
that's why I am not using it anymore now.
From: Larry Serflaten on

"Jeff Caton" <j.caton(a)gmailnotspam.com> wrote

> So when I say something like
>
> for each c in form.controls
> if typename(c) = "CommandButton" then
> c.caption = ...
>
> it will fail, because Timos controls use ".Text", not ".Caption".
>
> I am now trying to find out what kind of control I am dealing with.
> Therefore I am using
>
> If TypeOf(c) Is BtnLibCtlU.CommandButton
> (...)
>
> This works fine, but some of my projects don't reference this control,
> and I cannot compile. Making #IF statements (to see which project I am
> dealing with) looks like an overkill to me.
>
> What should I do? Should I simply reference the control, and don't care
> if it is not there at runtime? Could this throw an error under some
> strange circumstances?

Its that BtnLibCtlu that is the odd man out. How about you test for VB
controls and assign accordingly, or, use the alternate if its NOT a VB
control? EX:

For Each ctl In MyForm.Controls
If TypeName(ctl) = "CommandButton" Then
If TypeOf ctl Is VB.CommandButton Then
ctl.Caption = "This"
Else
ctl.Text = "That"
End If
End If
Next

You'd still want to include error handling to cover all the bases.

Just a suggestion....
LFS




From: Jeff Caton on
Great idea and funny because so simply!
Thanks!
From: Dee Earley on
On 15/06/2010 12:05, Jeff Caton wrote:
> Hello!
>
> All my project share some "common" modules where I have anything that I
> use in all projects.
>
> In one of this modules I have a function that translates captions and
> texts.
>
> I am using control from TimoSoft-software.de, and unfortunately he named
> his controls just like the VB6 controls.
>
> So when I say something like
>
> for each c in form.controls
> if typename(c) = "CommandButton" then
> c.caption = ...
>
> it will fail, because Timos controls use ".Text", not ".Caption".
>
> I am now trying to find out what kind of control I am dealing with.
> Therefore I am using
>
> If TypeOf(c) Is BtnLibCtlU.CommandButton
> (...)
>
> This works fine, but some of my projects don't reference this control,
> and I cannot compile. Making #IF statements (to see which project I am
> dealing with) looks like an overkill to me.
>
> What should I do? Should I simply reference the control, and don't care
> if it is not there at runtime? Could this throw an error under some
> strange circumstances?

I'd use a conditional compile constant to say that a given component is
in use.

I do similar for shared modules that take text that can be translated,
but not all projects have the translation code.

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
 | 
Pages: 1
Prev: Pictures
Next: .tlb crash