Try prepending the project's namespace in front of Form1. Also, you should check if OpenForms contains Form1 e.g.
Dim form1 = Application.OpenForms("form1")
If form1 IsNot Nothing
CType(form1, Form1).Text = "Hello"
End If
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi ,I call form1 in my module which is in console application.I receive "Type 'form1' is not defined" error.
I don't know how can I call form in module.
This is my code:
Imports System.Management
Imports System.Windows.Forms
Imports System.Runtime
Module module1
Public Class kh
Public Shared Sub dosomething()
Task.Run(Sub() updateform())
End Sub
Public Delegate Sub formdelegate()
Public Shared Sub updateform()
Dim f As form1 = Application.OpenForms("form1")
End Sub
Sub main()
'Dim f As New Form1
'Application.Run(Form1)
Console.WriteLine("ok")
End Sub
Please help
Thanks
Try prepending the project's namespace in front of Form1. Also, you should check if OpenForms contains Form1 e.g.
Dim form1 = Application.OpenForms("form1")
If form1 IsNot Nothing
CType(form1, Form1).Text = "Hello"
End If