Hi ,I want call a form from module and after that the form executed return to module.How can I do that?
Please explain it by an example.
Thanks
Hi ,I want call a form from module and after that the form executed return to module.How can I do that?
Please explain it by an example.
Thanks
If the form and module are included into your application (i.e. you have a single project that contains the form and module), then did you consider the usual technique, like ‘Dim f As New Form1 : f.ShowDialog()’?
Hi ,No thanks I didn't consider that.Please can you tell me what is f and why I have to use this statement?
F is a variable that will help to work with your form. You can use another name. You do not have to use this statement, but if you want to show the form, you can use it.
Hi,'try following console demo:
Imports System.Windows.Forms
Module Module1
Sub Main()
Try
Dim c As New Demo
c.Execute()
Catch ex As Exception
Console.WriteLine(ex.ToString)
End Try
Console.WriteLine("Continue enter key")
Console.ReadKey()
End Sub
Friend Class Demo
Friend Sub Execute()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Application.DoEvents()
Application.Run(New Form1()) ' instantiate new Form and show it '
End Sub
End Class
Friend Class Form1
Inherits Form
Private Label1 As New Label() With {.Text = "Form 1 loaded"}
Public Sub New()
AddHandler Me.Load, Sub()
Me.Controls.Add(Label1)
End Sub
End Sub
End Class
End Module
Please can you say me here which form is called and why you had used try statement?
Thanks
HI,
in console demo the Form1 class is instantiated and called.
try-catch I use because demo code is a part of more complex code where can be any error at run time.
5 people are following this question.