Results 1 to 14 of 14

Thread: Timer canot be converted to control in vb.net

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2018
    Posts
    10

    Timer canot be converted to control in vb.net

    I have the following code in VB.NET. It gives error that timer cannot be converted to type control.


    Code:
    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
    In Designer.vb form

    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)

    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)
    This calls the below functions.

    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 Function
    Note: I'm converting this project from VB6 to VB.NET and it works fine in VB6.
    Code:
    ctl = Timer1(a_instance)
    line throws error in VB.NET.
    Last edited by Himanshupatel06; Jun 21st, 2018 at 09:17 AM. Reason: Provided more code

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width