Thank you all
'
'if I click Display message no message are displayed becaus flag is False
'When i click the button falg false to flip it to flag True.
'the app do not react.
'
'how I can make this simple app to react when fliping bettween
'true and false
'I am very thank you for any help
'
'
Imports System
Imports System.Windows.Forms
Module m1
Sub Main()
Dim myForm As New Form1
myForm.ShowDialog()
End Sub
End Module
Public Class Form1
Dim message1 As String = Nothing
Dim flag As Boolean = False
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
LengthyTask()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
flag = Not flag
Me.Button2.Text = "Flag = " & flag.ToString
End Sub
Public Sub LengthyTask()
While True
If flag Then
Exit While
End If
End While
msgbox("TextBox1.Text = " & TextBox1.Text)
End Sub
End Class
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.Button1 = New System.Windows.Forms.Button()
Me.Button2 = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(102, 222)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(459, 22)
Me.TextBox1.TabIndex = 0
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(102, 124)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(234, 23)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Display Message"
Me.Button1.UseVisualStyleBackColor = True
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(362, 124)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(199, 23)
Me.Button2.TabIndex = 2
Me.Button2.Text = "Flag = False"
Me.Button2.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 16.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(688, 458)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
End Class