Message 1 of 9
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I have a form and I want to run the code for (MsgBox) whenever I click the button in my form (so I will see 2 messages whenever I click the button).
The problem is that it will show only after I close the form. How can I do this?
My code looks like this:
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
Public Sub Main()
Dim oForm As New WinForm(iLogicVb.Automation)
oForm.ShowDialog()
MsgBox("TASK 2")
End Sub
Public Class WinForm
Inherits System.Windows.Forms.Form
Public Sub New(ByVal Iinf As IiLogicAutomation)
oForm = Me
With oForm
.FormBorderStyle = FormBorderStyle.FixedToolWindow
.StartPosition = FormStartPosition.CenterScreen
.Width = 300
.Height = 400
.Text = "MYFORM"
.ShowInTaskbar = False
End With
Dim oButton1 As New Button()
With oButton1
.Text = "CLICK ME!"
.Top = oForm.Bottom - 80
.Left = (oForm.Width/2) - oButton1.Width
.Enabled = True
.AutoSize = True
End With
Me.Controls.Add(oButton1)
AddHandler oButton1.Click, AddressOf oButton1_Click
End Sub
Public Sub oButton1_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs)
MsgBox("TASK 1")
End Sub
End Class
Thank you.
Solved! Go to Solution.