Getting User data from a dialog form.
Getting User data from a dialog form.
am 11.10.2007 22:26:34 von dgleeson3
Hello all
I have used the LoginForm1 class in a Visual studio 2005 VB
application.
Its the standard Username, Pasword request for user input.
I was hoping to use property procedures to get back the user input in
the two boxes but its not working out.
The key sections of code is below. When Im debugging this and break
in
the property procedure I just get Nothing for Username_property
and Username.
Im used to doing this in C++ and can see there is something missing
but dont know what that is.
------------------------------------------------------------ ---------------=
=AD--
' First we put up Login form
' set the DialogResult for both buttons
If LoginForm_1.ShowDialog() <> DialogResult.OK Then
'close application
Environment.Exit(0)
' They did not want to log in so return to quit the
program
Return False
End If
------------------------------------------------------------ ---------------=
=AD--
< THEN LATER in the same function I want to use the values from the
form as follows. >
If
(DataBase_Manager1.CheckPassword(LoginForm1.Username_propert y,
LoginForm1.Password_property)) Then
'User failed to log in, either let him/her try again
'or end the program. In this case I just end the program.
Return False
End If
------------------------------------------------------------ ---------------=
=AD-
< I even have a private variable called Username taking the value
from
the text box when OK is pressed>
Private Username As String
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click
Username =3D UsernameTextBox.Text
End Sub
------------------------------------------------------------ ---------------=
=AD-
ReadOnly Property Username_property() As String
Get
' The Get property procedure is called when the value
' of a property is retrieved.
Return Username
End Get
End Property
------------------------------------------------------------ ---------------=
=AD--
Many thanks for all input.
Regards
Denis
______________________
Denis Gleeson
http://www.CentronSolutions.com
Re: Getting User data from a dialog form.
am 11.10.2007 23:15:39 von AMDRIT
Are your properties wired to your textbox controls?
it would seem to me that if you wanted to ask frmLogin for the username it
would look like this:
public class LoginForm
public readonly property UserName as string
get
return Me.txtUsername.text
end get
end property
'optionally you could make this read/write
public property UserName as string
get
return Me.txtUsername.text
end get
set (value as string)
if string.compare(me.txtusername.text,value) <> 0 then
me.txtusername.text = value
else
'no changes were made
exit property
end if
end set
end property
End Class
wrote in message
news:1192134394.880067.69330@d55g2000hsg.googlegroups.com...
Hello all
I have used the LoginForm1 class in a Visual studio 2005 VB
application.
Its the standard Username, Pasword request for user input.
I was hoping to use property procedures to get back the user input in
the two boxes but its not working out.
The key sections of code is below. When Im debugging this and break
in
the property procedure I just get Nothing for Username_property
and Username.
Im used to doing this in C++ and can see there is something missing
but dont know what that is.
------------------------------------------------------------ -----------------
' First we put up Login form
' set the DialogResult for both buttons
If LoginForm_1.ShowDialog() <> DialogResult.OK Then
'close application
Environment.Exit(0)
' They did not want to log in so return to quit the
program
Return False
End If
------------------------------------------------------------ -----------------
< THEN LATER in the same function I want to use the values from the
form as follows. >
If
(DataBase_Manager1.CheckPassword(LoginForm1.Username_propert y,
LoginForm1.Password_property)) Then
'User failed to log in, either let him/her try again
'or end the program. In this case I just end the program.
Return False
End If
------------------------------------------------------------ ----------------
< I even have a private variable called Username taking the value
from
the text box when OK is pressed>
Private Username As String
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click
Username = UsernameTextBox.Text
End Sub
------------------------------------------------------------ ----------------
ReadOnly Property Username_property() As String
Get
' The Get property procedure is called when the value
' of a property is retrieved.
Return Username
End Get
End Property
------------------------------------------------------------ -----------------
Many thanks for all input.
Regards
Denis
______________________
Denis Gleeson
http://www.CentronSolutions.com
Re: Getting User data from a dialog form.
am 11.10.2007 23:27:05 von AMDRIT
My mistake, I didn't see
Private Sub OK_Click(...) Handles OK.Click
Username = UsernameTextBox.Text
End Sub
So, um yes this is odd.
Put a break point on Username = UsernameTextBox.Text and test the value of
UsernameTextBox.Text.
"amdrit" wrote in message
news:%23blxfvEDIHA.5856@TK2MSFTNGP04.phx.gbl...
> Are your properties wired to your textbox controls?
>
> it would seem to me that if you wanted to ask frmLogin for the username it
> would look like this:
>
> public class LoginForm
>
> public readonly property UserName as string
> get
> return Me.txtUsername.text
> end get
> end property
>
> 'optionally you could make this read/write
>
> public property UserName as string
> get
> return Me.txtUsername.text
> end get
>
> set (value as string)
>
> if string.compare(me.txtusername.text,value) <> 0 then
> me.txtusername.text = value
> else
> 'no changes were made
> exit property
> end if
>
> end set
> end property
>
> End Class
>
>
> wrote in message
> news:1192134394.880067.69330@d55g2000hsg.googlegroups.com...
> Hello all
>
> I have used the LoginForm1 class in a Visual studio 2005 VB
> application.
> Its the standard Username, Pasword request for user input.
>
>
> I was hoping to use property procedures to get back the user input in
> the two boxes but its not working out.
>
>
> The key sections of code is below. When Im debugging this and break
> in
> the property procedure I just get Nothing for Username_property
> and Username.
>
>
> Im used to doing this in C++ and can see there is something missing
> but dont know what that is.
>
>
> ------------------------------------------------------------ -----------------
> ' First we put up Login form
> ' set the DialogResult for both buttons
> If LoginForm_1.ShowDialog() <> DialogResult.OK Then
> 'close application
> Environment.Exit(0)
> ' They did not want to log in so return to quit the
> program
> Return False
>
>
> End If
>
>
> ------------------------------------------------------------ -----------------
>
>
> < THEN LATER in the same function I want to use the values from the
> form as follows. >
>
>
> If
> (DataBase_Manager1.CheckPassword(LoginForm1.Username_propert y,
> LoginForm1.Password_property)) Then
> 'User failed to log in, either let him/her try again
> 'or end the program. In this case I just end the program.
> Return False
> End If
>
>
> ------------------------------------------------------------ ----------------
> < I even have a private variable called Username taking the value
> from
> the text box when OK is pressed>
>
>
> Private Username As String
>
>
> Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles OK.Click
> Username = UsernameTextBox.Text
>
>
> End Sub
> ------------------------------------------------------------ ----------------
> ReadOnly Property Username_property() As String
> Get
> ' The Get property procedure is called when the value
> ' of a property is retrieved.
>
>
> Return Username
>
>
> End Get
> End Property
>
>
> ------------------------------------------------------------ -----------------
>
>
> Many thanks for all input.
>
>
> Regards
>
>
> Denis
> ______________________
> Denis Gleeson
> http://www.CentronSolutions.com
>
>
Re: Getting User data from a dialog form.
am 12.10.2007 00:05:09 von dgleeson3
Hi
Thanks for your input.
Private Sub OK_Click(...) Handles OK.Click
Username =3D UsernameTextBox.Text
End Sub
This works fine. Username becomes the correct text string.
But by the time I try to return Username from the property procedure
Username has become nothing. Ive done a search and Im not setting it
to nothing anywhere.
Its something to do with the property procedure that I dont understand
or the persistance of values
in the instance of the dialog object after the dialog has been closed.
Many thanks for all input.
Regards
Denis
______________________
Denis Gleeson
http://www.CentronSolutions.com
On Oct 11, 10:27 pm, "amdrit" wrote:
> My mistake, I didn't see
>
> Private Sub OK_Click(...) Handles OK.Click
> Username =3D UsernameTextBox.Text
> End Sub
>
> So, um yes this is odd.
>
> Put a break point on Username =3D UsernameTextBox.Text and test the value=
of
> UsernameTextBox.Text.
>
> "amdrit" wrote in message
>
> news:%23blxfvEDIHA.5856@TK2MSFTNGP04.phx.gbl...
>
>
>
> > Are your properties wired to your textbox controls?
>
> > it would seem to me that if you wanted to ask frmLogin for the username=
it
> > would look like this:
>
> > public class LoginForm
>
> > public readonly property UserName as string
> > get
> > return Me.txtUsername.text
> > end get
> > end property
>
> > 'optionally you could make this read/write
>
> > public property UserName as string
> > get
> > return Me.txtUsername.text
> > end get
>
> > set (value as string)
>
> > if string.compare(me.txtusername.text,value) <> 0 then
> > me.txtusername.text =3D value
> > else
> > 'no changes were made
> > exit property
> > end if
>
> > end set
> > end property
>
> > End Class
>
> > wrote in message
> >news:1192134394.880067.69330@d55g2000hsg.googlegroups.com.. .
> > Hello all
>
> > I have used the LoginForm1 class in a Visual studio 2005 VB
> > application.
> > Its the standard Username, Pasword request for user input.
>
> > I was hoping to use property procedures to get back the user input in
> > the two boxes but its not working out.
>
> > The key sections of code is below. When Im debugging this and break
> > in
> > the property procedure I just get Nothing for Username_property
> > and Username.
>
> > Im used to doing this in C++ and can see there is something missing
> > but dont know what that is.
>
> > ------------------------------------------------------------ -----------=
------
> > ' First we put up Login form
> > ' set the DialogResult for both buttons
> > If LoginForm_1.ShowDialog() <> DialogResult.OK Then
> > 'close application
> > Environment.Exit(0)
> > ' They did not want to log in so return to quit the
> > program
> > Return False
>
> > End If
>
> > ------------------------------------------------------------ -----------=
------
>
> > < THEN LATER in the same function I want to use the values from the
> > form as follows. >
>
> > If
> > (DataBase_Manager1.CheckPassword(LoginForm1.Username_propert y,
> > LoginForm1.Password_property)) Then
> > 'User failed to log in, either let him/her try again
> > 'or end the program. In this case I just end the program.
> > Return False
> > End If
>
> > ------------------------------------------------------------ -----------=
-----
> > < I even have a private variable called Username taking the value
> > from
> > the text box when OK is pressed>
>
> > Private Username As String
>
> > Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles OK.Click
> > Username =3D UsernameTextBox.Text
>
> > End Sub
> > ------------------------------------------------------------ -----------=
-----
> > ReadOnly Property Username_property() As String
> > Get
> > ' The Get property procedure is called when the value
> > ' of a property is retrieved.
>
> > Return Username
>
> > End Get
> > End Property
>
> > ------------------------------------------------------------ -----------=
------
>
> > Many thanks for all input.
>
> > Regards
>
> > Denis
> > ______________________
> > Denis Gleeson
> >http://www.CentronSolutions.com- Hide quoted text -
>
> - Show quoted text -
Re: Getting User data from a dialog form.
am 12.10.2007 06:02:58 von notmyfirstname
Hi,
You are right, you have first to pass back the username to the dialogform to
get what you want.
'Although that you can get the username direct from the environment.username
and it is even more comfortable for your client to use the normal way using
the role bases security.
http://msdn2.microsoft.com/en-us/library/52kd59t0(VS.71).asp x
However to come back on your code problem
The normal contstruct of a dialogform is
\\\
dim dlg as New myDialogform
If LoginForm_1.ShowDialog() <> DialogResult.OK Then
Environment.Exit(0)
end if
Whatever = dlg.Username
dlg.Dispose
///
To use the dispose here is one of the exceptions where it is usefull,
because of the nature of a dialogform.
While I normally always use properties do I normally use (if possible)
direct Friend members for the dialogforms.
Cor
Re: Getting User data from a dialog form.
am 12.10.2007 16:30:15 von dgleeson3
Hi Cor
Yes more like C++ than I guessed.
Although Im not using the property procedures. Dialog forms are
probably not the place to use these.
Thanks for your help
Regards
Denis
______________________
Denis Gleeson
http://www.CentronSolutions.com
On Oct 12, 5:02 am, "Cor Ligthert[MVP]"
wrote:
> Hi,
>
> You are right, you have first to pass back the username to the dialogform to
> get what you want.
>
> 'Although that you can get the username direct from the environment.username
> and it is even more comfortable for your client to use the normal way using
> the role bases security.
>
> http://msdn2.microsoft.com/en-us/library/52kd59t0(VS.71).asp x
>
> However to come back on your code problem
>
> The normal contstruct of a dialogform is
>
> \\\
> dim dlg as New myDialogform
> If LoginForm_1.ShowDialog() <> DialogResult.OK Then
> Environment.Exit(0)
> end if
> Whatever = dlg.Username
> dlg.Dispose
> ///
>
> To use the dispose here is one of the exceptions where it is usefull,
> because of the nature of a dialogform.
>
> While I normally always use properties do I normally use (if possible)
> direct Friend members for the dialogforms.
>
> Cor