473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Getting User data from a dialog form.

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
5 1512
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve | last post by:
I'm working in PHP, but am also using JavaScript, so perhaps there is a better way to do this using more PHP code...... I setup a search screen for my database, the user enters data and submits...
1
by: Mohan | last post by:
Hi All, I am using web browser control in a VB 6.0 client server application to print reports. I am writing the report into a HTML file and displays the report to the user using the code,...
5
by: Don | last post by:
I have a need to submit a form, but don't need the user to click on a button. How do I do this? Is there some way, using JavaScript, to setup a <form> tag to do this? Thanks, Don ----==...
4
by: gimme_this_gimme_that | last post by:
Hi, This is sort of a : How to build a Yes/No dialog box qquestion. Or perhaps a question about getting javascript variables from a pop-up window and processing them on a submit. This is...
1
by: YYZ | last post by:
I've got a form in my application. From this form, I showdialog another form, like this: dim f as new frmWhatever f.someprop = somevalue f.showdialog() f.OkToClose = True f.close f = nothing
5
by: dgleeson3 | last post by:
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...
2
Megalog
by: Megalog | last post by:
Hey all, I have a minor issue I'm trying to figure out (using Access 2007). I'm using a DAO recordset to update a table ("Writeups"), with the results of a bunch of functions I've written up over...
3
by: ArmageddonAsh | last post by:
I'm trying to make an application that will allow the user to enter data into a flexgrid (that's done) and then save the data from that flexgrid into a CSV file but even though the file is made none...
2
DonRayner
by: DonRayner | last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm...
7
by: Sin Jeong-hun | last post by:
I have a dialog form which pops up from the main window using the ShowDialog() method. this dialog has no or button, and it has quite a lot of controls on it. Now, I want to close this dialog...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.