By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,464 Members | 1,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,464 IT Pros & Developers. It's quick & easy.

Getting User data from a dialog form.

P: n/a
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.Userna me_property,
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

Oct 11 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
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
<dg*******@eircom.netwrote in message
news:11*********************@d55g2000hsg.googlegro ups.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.Userna me_property,
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
Oct 11 '07 #2

P: n/a
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" <am****@hotmail.comwrote in message
news:%2****************@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
<dg*******@eircom.netwrote in message
news:11*********************@d55g2000hsg.googlegro ups.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.Userna me_property,
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


Oct 11 '07 #3

P: n/a
Hi

Thanks for your input.

Private Sub OK_Click(...) Handles OK.Click
Username = 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" <amd...@hotmail.comwrote:
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 valueof
UsernameTextBox.Text.

"amdrit" <amd...@hotmail.comwrote in message

news:%2****************@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 usernameit
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
<dglees...@eircom.netwrote in message
news:11*********************@d55g2000hsg.googlegro ups.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.Userna me_property,
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- Hide quoted text -

- Show quoted text -

Oct 11 '07 #4

P: n/a
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/lib...t0(VS.71).aspx

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

Oct 12 '07 #5

P: n/a
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]" <notmyfirstn...@planet.nl>
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/lib...t0(VS.71).aspx

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

Oct 12 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.