Vb.net 2015 проблема Запомни меня
Всем Привет
У меня есть проблема с опцией Запомнить меня.
Когда я использую
Меня.Скрыть()
Формы Form2.Показать()
в следующий раз когда я открою программу она запомнит имя пользователя и пароль
но если я использую
Формы Form2.Показать()
Меня.Рядом()
В следующий раз, когда я открою сеанс программы, это = True, но имя пользователя и пароль исчезли wtf??
Может ли кто-нибудь проверить это и сказать мне, как это исправить или где я ошибаюсь .
Спасибо
мой код:
Imports MySql.Data.MySqlClient Public Class Form1 Dim MysqlConn As MySqlConnection Dim Command As MySqlCommand Private WithEvents tmr As New Timer With {.Interval = 15} Dim SAPI 'use for voice 'Use for move screen Private IsFormBeingDragged As Boolean = False Private MouseDownX As Integer Private MouseDownY As Integer 'end Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load If My.Settings.Session = True Then txtuser.Text = My.Settings.Username txtpass.Text = My.Settings.Password CheckBox1.Checked = True Else 'Sleep CheckBox1.Checked = False End If End Sub Private Sub tmr_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles tmr.Tick ProgressBarEx1.Value += 1 If ProgressBarEx1.Value = 100 Then tmr.Stop() ProgressBarEx1.ShowPercentage = False ProgressBarEx1.ShowText = True ProgressBarEx1.Text = "Finished" 'Now make connection Dim conn As MySqlConnection Dim cmd As New MySqlCommand conn = New MySqlConnection conn.ConnectionString = "server=localhost;port=3306;userid=root;password=password21;database=ycdata" Dim Reader As MySqlDataReader Try conn.Open() Dim query As String query = "select ucode from users where uname= '" & txtuser.Text & "' and upassword = '" & txtpass.Text & "' " cmd = New MySqlCommand(query, conn) Reader = cmd.ExecuteReader Dim count As Integer count = 0 While Reader.Read count = count + 1 End While If count = 1 Then Dim usertype = Reader.GetString("ucode") If usertype = "1" Then SAPI = CreateObject("SAPI.spvoice") SAPI.Speak("Welcome" & txtuser.Text) 'MsgBox("Welcome Admin") For j = 0 To 500 Next Me.Hide() Form2.Show() 'Me.Close() If CheckBox1.Checked = True Then My.Settings.Session = True My.Settings.Username = txtuser.Text My.Settings.Password = txtpass.Text My.Settings.Save() My.Settings.Reload() ElseIf CheckBox1.Checked = False Then My.Settings.Session = False My.Settings.Username = String.Empty My.Settings.Password = String.Empty My.Settings.Reset() My.Settings.Save() My.Settings.Reload() End If conn.Close() conn.Dispose() ElseIf usertype = "0" Then For j = 0 To 500 Next SAPI = CreateObject("SAPI.spvoice") SAPI.Speak("Welcome" & txtuser.Text) 'MsgBox("Welcome Normal User") 'Me.Hide() Form3.Show() Me.Close() If CheckBox1.Checked = True Then My.Settings.Session = True My.Settings.Username = txtuser.Text My.Settings.Password = txtpass.Text My.Settings.Save() My.Settings.Reload() ElseIf CheckBox1.Checked = False Then My.Settings.Session = False My.Settings.Username = String.Empty My.Settings.Password = String.Empty My.Settings.Reset() My.Settings.Save() My.Settings.Reload() End If ElseIf usertype > 1 Then MsgBox("Error: User Details #1") End If Else 'MsgBox("User does not exist!") SAPI = CreateObject("SAPI.spvoice") SAPI.Speak("Please Try Again") txtuser.Text = "" txtpass.Text = "" txtuser.Focus() End If conn.Close() Catch ex As Exception MessageBox.Show(ex.Message) Finally txtuser.Text = "" txtpass.Text = "" End Try End If End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click If txtpass.Text = "" Or txtuser.Text = "" Then MessageBox.Show("Please Fill in Empty TextBox!", "Error") txtuser.Focus() Else lblStatus.Visible = True ProgressBarEx1.Visible = True ProgressBarEx1.Value = 0 ProgressBarEx1.ShowPercentage = True ProgressBarEx1.ShowText = False tmr.Start() End If End Sub Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click 'executes when PictureBox1 is clicked If txtpass.UseSystemPasswordChar = True Then txtpass.UseSystemPasswordChar = False Else txtpass.UseSystemPasswordChar = True End If End Sub Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click If txtuser.Text = "" And txtpass.Text = "" Then MsgBox("Sorry its already empty") Else CheckBox1.Checked = False My.Settings.Session = False My.Settings.Username = String.Empty My.Settings.Password = String.Empty My.Settings.Reset() My.Settings.Save() txtuser.Text = "" txtpass.Text = "" txtuser.Focus() End If End Sub Private Sub PictureBox4_Click(sender As Object, e As EventArgs) Handles PictureBox4.Click Application.Exit() End Sub 'Start Move Screen Code Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown If e.Button = MouseButtons.Left Then IsFormBeingDragged = True MouseDownX = e.X MouseDownY = e.Y End If End Sub Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp If e.Button = MouseButtons.Left Then IsFormBeingDragged = False End If End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove If IsFormBeingDragged Then Dim newLocation As Point = New Point() newLocation.X = Me.Location.X + (e.X - MouseDownX) newLocation.Y = Me.Location.Y + (e.Y - MouseDownY) Me.Location = newLocation newLocation = Nothing End If End Sub Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged End Sub 'End Move Screen Code End Class
Что я уже пробовал:
Я пробовал варианты с моей.параметры.сохранить
мой.установка.перезагрузить
мой.установка.сбросить
никакой помощи от этого нет, только если мой form1.hide() то он работает, но я хочу закрыть form1 и перейти к form2 или form3 и в следующий раз при входе в программу запомнить имя.