Vb Net form User input

Would anyone be able to help figure out why my username and password will not be stored as variables from the below vb net form. I have looked everywhere and can not get it

  	Dim form As New System.Windows.forms.form 
	Dim button As New System.Windows.Forms.Button()
	
    
	checkedListBox1 = New System.Windows.Forms.CheckedListBox()
    textBox1 = New System.Windows.Forms.TextBox()
    textboxPass = New System.Windows.Forms.MaskedTextBox()
    labelUser = New System.Windows.Forms.Label()
    labelPassword= New System.Windows.Forms.Label()
    
    
  
    textBox1.Location = New System.Drawing.Point(79, 26)
    textBox1.Name = "TextBox1"
    textBox1.Size = New System.Drawing.Size(196, 20)
    textBox1.TabIndex = 0
	textBox1.Enabled = true
		
    '
    'MaskedTextBox1
    '
    textboxPass.Location = New System.Drawing.Point(79, 66)
    textboxPass.Name = "MaskedTextBox1"
    textboxPass.Size = New System.Drawing.Size(196, 20)
    textboxPass.TabIndex = 1
	textboxPass.UseSystemPasswordChar = True
    '
    'Username
    '
    labelUser.AutoSize = True
    labelUser.Location = New System.Drawing.Point(12, 29)
    labelUser.Name = "Username"
    labelUser.Size = New System.Drawing.Size(55, 13)
    labelUser.TabIndex = 2
    labelUser.Text = "Username"
    '
    'Password
    '
    labelPassword.AutoSize = True
    labelPassword.Location = New System.Drawing.Point(12, 66)
    labelPassword.Name = "Password"
    labelPassword.Size = New System.Drawing.Size(53, 13)
    labelPassword.TabIndex = 3
    labelPassword.Text = "Password"
    '
    'Button1
    '
    button.Location = New System.Drawing.Point(47, 360)
    button.Name = "button"
    button.Size = New System.Drawing.Size(211, 23)
    button.TabIndex = 4
    button.Text = "Login"
    button.UseVisualStyleBackColor = True
	AddHandler button.Click, Sub(sender As Object,e As EventArgs) form.Close()
   
	
	
	checkedListBox1.FormattingEnabled = True
    checkedListBox1.Location = New System.Drawing.Point(48, 111)
    checkedListBox1.Name = "chkSelectOptions"
    checkedListBox1.Items.AddRange(sources)
    checkedListBox1.Size = New System.Drawing.Size(200, 200)
    checkedListBox1.TabIndex = 0

’
'Form1
’

    AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
    AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
    form.ClientSize = New System.Drawing.Size(400, 400)
    form.Controls.Add(button)
    form.Controls.Add(labelPassword)
    form.Controls.Add(labelUser)
    form.Controls.Add(textboxPass)
    form.Controls.Add(textBox1)
	form.Controls.Add(checkedListBox1)
	'textBox1.Text = ""
	
	
	
    form.Name = "Form1"
    form.Text = "Form1"
	form.AcceptButton = button
	'username = Me.textBox1.text.ToString
	username = textBox1.Text.ToString
	unsecurePass = textBoxPass.Text.ToString
	form.ShowDialog()
1 Like

form.ShowDialog causes the form to run in it’s own memory space within the .net program, think modal dialog. Your variables would need to be global and defined properly in out parameters and after the form closes they will output.