I have the following code in VB.NET. It gives error that timer cannot be converted to type control.
In Designer.vb formCode:Dim ctl As System.Windows.Forms.Control Timer1.Load(a_instance) ctl = Timer1(a_instance) DisplayForm_GetDisplay = ctl If a_instance = 1 Then ReDim tmrevtback(1) End If
Code:Public WithEvents Timer1 As Microsoft.VisualBasic.Compatibility.VB6.TimerArray Me.Timer1 = New Microsoft.VisualBasic.Compatibility.VB6.TimerArray(Me.components)
EDIT:
Code:Dim lctl As System.Windows.Forms.Control lctl = mDisplayForm.GetDisplayElementControl(a_elemtype, i, a_displayelement)
This calls the below functions.Code:Private Function DisplayForm_GetDisplayElementControl(ByRef a_type As String, ByRef a_instance As Integer, ByRef a_displayelement As DisplayEvent) As System.Windows.Forms.Control Implements _DisplayForm.GetDisplayElementControl Dim ctl As System.Windows.Forms.ControlDim ctl As System.Windows.Forms.Control Timer1.Load(a_instance) ctl = Timer1(a_instance) DisplayForm_GetDisplayElementControl= ctl If a_instance = 1 Then ReDim tmrevtback(1) End If If UBound(tmrevtback) < a_instance Then ReDim Preserve tmrevtback(a_instance) End If tmrevtback(a_instance) = a_displayelement frmDisplayToolbox.RegisterNewControl(Me, a_type, a_instance, a_displayelement, ctl)
Note: I'm converting this project from VB6 to VB.NET and it works fine in VB6.Code:Public Function RegisterNewControl(ByRef a_form As System.Windows.Forms.Form, ByRef a_type As String, ByVal a_instance As Integer, ByRef a_displayelement As DisplayElement, ByRef a_control As System.Windows.Forms.Control) As Boolean Dim lkey As String = "" Dim levent As String = "" Dim lparms As DataSetNode On Error GoTo bad If a_form Is mForm Or mForm Is Nothing Then lkey = "k" & a_type & a_instance If Not a_control Is Nothing Then mDisplayInstances.Add(a_type & a_instance) mDisplayControls.Add(a_control, lkey) mDisplayElements.Add(a_displayelement, lkey) mLog("+ Register New Control: K=" & lkey) RegisterNewControl = True Else mLog("!! Unable to Register New Control (control is empty): T=" & a_type & " I=" & a_instance) End If Else mLog("!! Unable to Register New Control (no or bad form): T=" & a_type & " I=" & a_instance) End If Exit Functionline throws error in VB.NET.Code:ctl = Timer1(a_instance)




Reply With Quote
