开发者

How to find the TypeOf a VB6 control in VB.NET

I am writing a .NET DLL to iterate through all controls in the a VB6 Form passed byref.

So far it seems to work VB.NET code:

Public Sub AddFormRefLegacy(ByRef strAppName As String, ByRef objForm As Object)

        'update the forms caption
        objForm.Capt开发者_Go百科ion = FindValue(strAppName, objForm.Name, "", "0", objForm.Caption)

        'iterate through all the controls on the form          
        For Each ctl As Object In objForm.Controls
           if TypeOf ctl is Label then
             'this doesn't pick up any labels
           end if
        Next
    End Sub

Called from this VB6 code:

Dim libDD As New Lib.clsDataDictionary
libDD.AddFormRefLegacy "nnne", Me

but the TypeOf operator does not work. Is there another way to find the type of control?


Could it be you're comparing two different "Label" type objects.

You haven't qualified the LABEL type in the IF TYPEOF line, so you could be comparing a VB6 label to a .net label, and they wouldn't be the same.

You could use TYPENAME, but that might not be exactly what you need iether. I'd make sure you're really comparing the types that you think you're comparing.


Have you tried using the TypeName function? Does it return anything useful for TypeName(ctl)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜