Procedo con il secondo form, Connect.vbE infine il modulo Connection.vbcodice:Imports WindowsApplication14.Connection Public Class Form2 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) 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. Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents txtPort As System.Windows.Forms.TextBox Friend WithEvents txtHost As System.Windows.Forms.TextBox Friend WithEvents Button3 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form2)) Me.GroupBox1 = New System.Windows.Forms.GroupBox() Me.Button3 = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() Me.Label3 = New System.Windows.Forms.Label() Me.Label2 = New System.Windows.Forms.Label() Me.txtPort = New System.Windows.Forms.TextBox() Me.txtHost = New System.Windows.Forms.TextBox() Me.GroupBox1.SuspendLayout() Me.SuspendLayout() ' 'GroupBox1 ' Me.GroupBox1.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button3, Me.Button1, Me.Label3, Me.Label2, Me.txtPort, Me.txtHost}) Me.GroupBox1.Location = New System.Drawing.Point(8, 8) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(296, 152) Me.GroupBox1.TabIndex = 0 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "GroupBox1" ' 'Button3 ' Me.Button3.BackColor = System.Drawing.SystemColors.GrayText Me.Button3.ForeColor = System.Drawing.Color.Black Me.Button3.Image = CType(resources.GetObject("Button3.Image"), System.Drawing.Bitmap) Me.Button3.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft Me.Button3.Location = New System.Drawing.Point(192, 104) Me.Button3.Name = "Button3" Me.Button3.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Button3.Size = New System.Drawing.Size(80, 25) Me.Button3.TabIndex = 12 Me.Button3.Text = "Annulla" Me.Button3.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'Button1 ' Me.Button1.BackColor = System.Drawing.SystemColors.GrayText Me.Button1.ForeColor = System.Drawing.Color.Black Me.Button1.Image = CType(resources.GetObject("Button1.Image"), System.Drawing.Bitmap) Me.Button1.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft Me.Button1.Location = New System.Drawing.Point(32, 104) Me.Button1.Name = "Button1" Me.Button1.RightToLeft = System.Windows.Forms.RightToLeft.No Me.Button1.Size = New System.Drawing.Size(104, 25) Me.Button1.TabIndex = 10 Me.Button1.Text = "Try Connect" Me.Button1.TextAlign = System.Drawing.ContentAlignment.MiddleRight ' 'Label3 ' Me.Label3.Location = New System.Drawing.Point(16, 64) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(74, 15) Me.Label3.TabIndex = 9 Me.Label3.Text = "Port" Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(16, 32) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(74, 15) Me.Label2.TabIndex = 8 Me.Label2.Text = "IP Address" ' 'txtPort ' Me.txtPort.Location = New System.Drawing.Point(112, 64) Me.txtPort.Name = "txtPort" Me.txtPort.Size = New System.Drawing.Size(78, 20) Me.txtPort.TabIndex = 7 Me.txtPort.Text = "80" ' 'txtHost ' Me.txtHost.Location = New System.Drawing.Point(112, 32) Me.txtHost.Name = "txtHost" Me.txtHost.Size = New System.Drawing.Size(142, 20) Me.txtHost.TabIndex = 6 Me.txtHost.Text = "" ' 'Form2 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.Black Me.ClientSize = New System.Drawing.Size(312, 174) Me.ControlBox = False Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1}) Me.ForeColor = System.Drawing.Color.Gold Me.Name = "Form2" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "HS Connection" Me.GroupBox1.ResumeLayout(False) Me.ResumeLayout(False) End Sub #End Region Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Me.Close() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Connection.Connection = True Me.Close() End Sub Private Sub txtHost_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtHost.TextChanged Connection.HostAddress = txtHost.Text End Sub Private Sub txtPort_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPort.TextChanged Connection.ConnectPort = txtPort.Text End Sub End ClassPerò quando si avvia clicco sul pulsante conetti, inserisco i parametri e non si connette, cambiando poi manualmente la variabile booleana, si avvia già connesso, ma non si disconnette!codice:Module Connection Public Connection As Boolean = True Public HostAddress As String = "0.0.0.0" Public ConnectPort As String = "80" End Module
Perchè mi fa questo??

Rispondi quotando