reset form
-
This is the code: Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click TextBox1 = Nothing TextBox2 = Nothing TextBox3 = Nothing TextBox5 = Nothing TextBox6 = Nothing DateOfbirth = Now TextBox7 = Nothing TextBox8 = Nothing TextBox9 = Nothing TextBox10 = Nothing TextBox11 = Nothing Department = "Administration" personal = New Personal when i click the rest button nothing happens. when i use Form.reset() it doesnt change anything either. Can someone please help? :confused: -- modified at 20:16 Tuesday 4th April, 2006
-
This is the code: Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click TextBox1 = Nothing TextBox2 = Nothing TextBox3 = Nothing TextBox5 = Nothing TextBox6 = Nothing DateOfbirth = Now TextBox7 = Nothing TextBox8 = Nothing TextBox9 = Nothing TextBox10 = Nothing TextBox11 = Nothing Department = "Administration" personal = New Personal when i click the rest button nothing happens. when i use Form.reset() it doesnt change anything either. Can someone please help? :confused: -- modified at 20:16 Tuesday 4th April, 2006
That is because you are not doing anything at all to the controls. The TextBox1 variable is not a textbox, it's only a reference to the textbox. When you set the variable to Nothing, you are only throwing away your reference to the control. That doesnt affect the control the least bit, it couldn't care less whether you have a reference to it or not. If you want to change the contents of the control, set the Text property of the control. --- b { font-weight: normal; }
-
That is because you are not doing anything at all to the controls. The TextBox1 variable is not a textbox, it's only a reference to the textbox. When you set the variable to Nothing, you are only throwing away your reference to the control. That doesnt affect the control the least bit, it couldn't care less whether you have a reference to it or not. If you want to change the contents of the control, set the Text property of the control. --- b { font-weight: normal; }
Thankyou heaps i have got it to work now. your a great help. :-D just one more thing, im trying to get my application to send an email to the user if they forget their password, the code is: If My.User Is Authenticated Then txtUser.Text = My.User.Name If userExists(My.User.Name) Then txtPassword.Focus() Else : NewUser = True MessageBox.Show("You are new to the system, please select request account and enter your details", "User Information") End If Else if MessageBox.Show("Sorry you are not authenticated to use this program" & vbNewLine & "If you are a staff member please select help or contact us") End If im not sure how to declair Authenticated,userExists and new user. With userExists i need to get it to check the database where all the users are stored yes? but im not to sure how to do this :omg:
-
Thankyou heaps i have got it to work now. your a great help. :-D just one more thing, im trying to get my application to send an email to the user if they forget their password, the code is: If My.User Is Authenticated Then txtUser.Text = My.User.Name If userExists(My.User.Name) Then txtPassword.Focus() Else : NewUser = True MessageBox.Show("You are new to the system, please select request account and enter your details", "User Information") End If Else if MessageBox.Show("Sorry you are not authenticated to use this program" & vbNewLine & "If you are a staff member please select help or contact us") End If im not sure how to declair Authenticated,userExists and new user. With userExists i need to get it to check the database where all the users are stored yes? but im not to sure how to do this :omg:
on the topic of email, this is how I do it for VB forms. it also works when exposed through a web service. Imports system.net.Mail public class mailer Private email As MailMessage Private webmailer As System.Net.Mail.SmtpClient Private Sub sendMail() email = New MailMessage("Sender Email", "Reciepient Email", "Subject Text", _ "Body Text") webmailer = New System.Net.Mail.SmtpClient("SMTP Server Name as String", _ "SMTP service port: usually 25") With email .Attachments(0) = New Attachment("c:\SomeFile.txt") .Attachments(1) = New Attachment("c:\SomeOtherFile.txt") End With webmailer.Send(email) End Sub end class server admin has a big impact on whether this will work. if it fails it may not be the code, but the smtp server configuration. good luck hey...slang is the vernacular for the vernacular...wow -- modified at 21:35 Tuesday 4th April, 2006
-
This is the code: Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click TextBox1 = Nothing TextBox2 = Nothing TextBox3 = Nothing TextBox5 = Nothing TextBox6 = Nothing DateOfbirth = Now TextBox7 = Nothing TextBox8 = Nothing TextBox9 = Nothing TextBox10 = Nothing TextBox11 = Nothing Department = "Administration" personal = New Personal when i click the rest button nothing happens. when i use Form.reset() it doesnt change anything either. Can someone please help? :confused: -- modified at 20:16 Tuesday 4th April, 2006
Make sure you are setting the .Text property to "" or String.Empty. You are attemting to set the Controls (TextBox1, TextBox2, etc.) to Nothing. Example TextBox1.Text = String.Empty This also works TextBox1.Clear Hope this helps :-D "Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem." ( President Ronald Reagan)