I ve got a propertyin my class that I have given the task of holding the username of the person that logged in and I would want to access that username in another form anoother time.How do I go about this? this is the code for my property:
Private _LogInUser As String = String.Empty
Public Property LogINUserName() As String
Get
Return _LogInUser
'LogINUserName = _LogInUser
End Get
Set(ByVal value As String)
_LogInUser = value
End Set
End Property
this is how I am assigning my value to the property in my login form
'Private comm1 As CommManager = New CommManager' the new instance of the class
Dim sql As String = "SELECT reference,UserName,UserPassword,UserCompany FROM Users WHERE UserCompany = '" & cmbCompany.Text & "' "
Conn.Open()
Dim dt As DataTable = New DataTable
Dim dscmd As New OleDbDataAdapter(sql, Conn)
dscmd.Fill(dt) Conn.Close()
If dt.Rows(0)("UserName") = cmbUsername.Text Then
If dt.Rows(0)("UserPassword") = txtPassword.Text Then
comm1.LogINUserName = dt.Rows(0)("UserName").ToString 'Assign my value right here
'MsgBox(comm1.LogINUserName) frmMenu.Show()
Else MsgBox("Wrong Password and/or Username") '***In the case of wrong Password
Exit Sub
End If
Else
MsgBox("Wrong Password and/or Username") '***In the case of wrong UserName Exit Sub End If
how I expect to get my value
Label11.Text = comm1.LogINUserName