|
-
Jul 3rd, 2007, 12:30 AM
#1
Thread Starter
Addicted Member
[2005] Application.Quit() giving an error
When I click my Exit Program button, it says
Code:
Object reference not set to an instance of an object.
And sometimes I don't quite remember but it says something along the line of
RoundRobinPro is Disposed... (My Main app)
This is my login form, which I have made, the code I use is below
Code:
Option Strict On
Option Explicit On
Public Class LoginForm1
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginButton.Click
Dim quit As Boolean = True
If SignupRadio.Checked Then
If System.IO.Directory.Exists("C:\Program Files\Round Robin Pro\Variables\" & _
UsernameTextBox.Text) Then
quit = False
Else
System.IO.Directory.CreateDirectory("C:\Program Files\Round Robin Pro\Variables\" & _
UsernameTextBox.Text)
RoundRobinPro.Dir.UsernameDir = RoundRobinPro.fnc _
.CapitalizeString(UsernameTextBox.Text)
MsgBox("Your account has been created", MsgBoxStyle.OkOnly)
End If
End If
Dim errorString As String = ""
If LoginRadio.Checked Then
If Not UsernameTextBox.Text.Length > 4 Then
quit = False
errorString &= "Your username must be atleast 5 characters long." & ControlChars.NewLine
End If
If Not PasswordTextBox.Text.Length > 4 Then
quit = False
errorString &= "Your password must be atleast 5 characters long." & ControlChars.NewLine
End If
If Not ConfirmPw_t.Text.Length > 4 Then
quit = False
errorString &= "Your confirm password must be atleast 5 characters long." & _
ControlChars.NewLine
End If
End If
If quit Then
Me.Close()
Else
MsgBox(errorString)
End If
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Close()
End Sub
Private Sub Timer123_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer123.Tick
If SignupRadio.Checked Then
ConfirmPw_t.Visible = True
ConfirmPw_l.Visible = True
LoginButton.Text = "Signup"
Else
ConfirmPw_t.Visible = False
ConfirmPw_l.Visible = False
LoginButton.Text = "Login"
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Application.Exit()
End Sub
End Class
Anyone know what's wrong?
Cheater's prosper, just not in a good way.
-
Jul 3rd, 2007, 11:15 PM
#2
Thread Starter
Addicted Member
Re: [2005] Application.Quit() giving an error
Bumpedy Bump, Does anyone know, I still have not figured it out
Cheater's prosper, just not in a good way.
-
Jul 4th, 2007, 12:52 AM
#3
Fanatic Member
Re: [2005] Application.Quit() giving an error
Instead of Application.Exit(), just try End. Like this:
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End
End Sub

In the unlikely event that I answer your question correctly, please Rate my post
Using Visual Studio 2005 Professional 
-
Jul 4th, 2007, 02:35 AM
#4
Re: [2005] Application.Quit() giving an error
END is not a good practice, thought it may help you here it may become an unhealthy habit.
You should create a try catch block or try to do yourform.hide instead of .close
-
Jul 4th, 2007, 03:16 AM
#5
Re: [2005] Application.Quit() giving an error
End is a Legacy function from VB6 and shouldnt be used in .NET.
Where are you creating the object "RoundRobinPro"? Seems its not created so when you try to access one of its properties or methods you will get that exact error.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jul 4th, 2007, 11:12 AM
#6
Fanatic Member
Re: [2005] Application.Quit() giving an error
 Originally Posted by RobDog888
End is a Legacy function from VB6 and shouldnt be used in .NET.
oh wow I wasn't aware it was bad practice. Learn something new every day 
Thanks!

In the unlikely event that I answer your question correctly, please Rate my post
Using Visual Studio 2005 Professional 
-
Jul 5th, 2007, 01:54 PM
#7
Re: [2005] Application.Quit() giving an error
It was the only way to end a BASIC program, because there was no window to close or object to dispose of. Forget that you can use End on a line by itself (End Sub and End Function are mandatory) and you'll save yourself a lot of grief in the future.
As one of the posters here says, closing the form is like escorting your guests to the street after the party is over. Using End is like pushing them off the 25th floor balcony. Either way will get them to the street, and the balcony route is faster, but ...
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jul 5th, 2007, 02:07 PM
#8
Re: [2005] Application.Quit() giving an error
yeah just look at the documentation for END, while its pretty complete documentation, there are several places in it where they advise against using it.
http://msdn2.microsoft.com/en-us/lib...ba(VS.80).aspx
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|