|
The best way to terminate your program is to catch Form Closing event & if button click. In Form Closing, add the following lines:
<object instances=""> = nothing
Me.Dispose()
GC.Collect()
Make sure that you make all of the objects created as Nothing, and then call Me.Dispose. For eg.,
Dim myDataGrid as DataGrid
Dim obj as Object
....
in Form Closing
myDataGrid = Nothing
obj = Nothing
This will make all the objects used as Null & free up all the memory. To remove all such object permanently, it is recommended to use GC.Collect(). GC frees all vars. as Nothing or not used from the memory. This is an Object Oriented concept.
Hope this helps.
Thanks
Terry
|
|
|
|
|
Thanks for your help, but I need the answer for VB6. Does it work the same way?
"Go to, I’ll no more on’t; it hath made me mad." - Hamlet
|
|
|
|
|
I believe it will work. 99% GC line wont work. Stil, I m not sure. Check out. If it gives error, remove it & try. Rest all remains the same.
Thanks
Terry
|
|
|
|
|
The MDI form's QueryUnload method probably has something that prevents your form from closing...
|
|
|
|
|
For anyone else having this problem, I found this article very helpful:
http://vbcity.com/forums/topic.asp?tid=99480[^]
The problem was, I wasn't unloading the child forms last. I was running code after the unload was called. The code reloaded them, and then the parent form ended with them still in memory. Close the child forms last.
"Go to, I’ll no more on’t; it hath made me mad." - Hamlet
|
|
|
|
|
Hi to all!!
I need a major project in visual basic...kindly help me out!!!
|
|
|
|
|
so you're looking for an idea for a major project, is that what you mean, how bout some specifics:
what did you already have in mind,?
what does it need to cover, topics etc?
what are you must comfortable with out of those topics?
|
|
|
|
|
Seriously, how is anyone supposed to answer this question?
There's is nothing here on what you know, the size of your team, if any, if there is any goal in doing to the project, what you intend to learn, industries your interested in, other projects you've done.
You've given us nothing to go on.
So, I can suggest a few. A control system for a nuclear power plant. Maybe a flight control system for an airliner. Engine and power management for the worlds largest container ships.
Those are all major projects...
|
|
|
|
|
Hello,
How can we recover deleted files in any format like .doc, .txt, .mdb from hard disk.
If anybody knows, please give URL or sample code.
Thanks & Regards,
Kumar
|
|
|
|
|
There's lots of stuff out there.
If you want to write your own, there is no URL I can give you. You must simplely know, and have experience with, file systems, especially NTFS and FAT, like you know the back of your hand.
|
|
|
|
|
Hi Dave Kreskowiak,
Thanks a lot for giving hint.
Thanks & Regards,
Kumar
|
|
|
|
|
Hi, I have written a simple program to better understand the concept of variable scope and I'd like your help in explaining a few things. My program simulates a ticketmaster, using a bunch of buttons to represent the number of available seats to a show. Every time a customer clicks on a button, its color turns from gray to blue. One seat will be subtracted from the total number of available seats when each button is clicked. I have created a global integer variable TotalSeats which represents the total number of seats available. The following code snippets are for the button which represents the first seat, and for the SHOW button to show the total number of available seats.
<br />
Dim TotalCount As Integer = 30<br />
<br />
Private Sub Seat1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Seat1.Click<br />
Dim A As Integer = 0<br />
While A < 1<br />
Seat1.BackColor = System.Drawing.Color.Blue<br />
A += 1<br />
TotalCount -= 1<br />
<br />
End While<br />
End Sub<br />
<br />
Private Sub SHOW_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SHOW.Click<br />
<br />
Label1.Text = TotalCount<br />
End Sub
Please answer the following 2 questions, thank you in advance for your help.
1) I thought that TotalCount is a global variable and even though its being used in a private Sub, its should still be visible to the SHOW button, why does Label1 show that TotalCount is 30 and not 29?
2) How do I group all the seat buttons together so that I can use just one requiredvalidator for all of them?
|
|
|
|
|
It sounds like you are getting confused about the lifecycle of the pages in ASP.Net. Your scoping is correct. However your instance of this page class is created when the browser makes the request, then it renders the page, then the instance is disposed. This means that when your Click event handler is running, it is a totally new instance of the class, with a freshly initialized TotalCount.
You need to read up on the "asp.net page lifecycle" (google it), and look at how you can store information you need between requests in the ViewState.
|
|
|
|
|
Your code works well in Desktop Application
But You are using Web Appl so you have to clear about that
In Web App the client is on remote location when request arrives on server, it create new instance and send response to the client.
so when you click on button it generate new request to the server and it create new instance so you get refreshed value of Total Count.
Best Regards,
Chetan Patel
|
|
|
|
|
I'm using a WebBrowser Control to log into a website and download financial statements. I have IE6 installed and am using VB 2005 Express Edition. My problem is that I cannot suppress the dialog box which states "Security Alert - You are about to be redirected to a connection that is not secure".
I have tried hacking the registry without success (I understand WebBrowser Control uses standard IE6 SP1 settings) and cannot use SendKeys as I need this to run in the background. I can't see that CoInternetSetFeatureEnabled has the correct feature either. My last resort was to try IDocHostShowUI::ShowMessage but I can't find any sample code for VB to try out.
Having wasted around 12 hours of my life trying to find a solution i'm happy to make a financial donation to the first person to help me solve this issue!
Many thanks in advance,
Jonny
|
|
|
|
|
Hi Jonny,
If this is a task that should occur in the background, you might have a lot more luck with the System.Net.WebClient class.
Hope this helps,
|
|
|
|
|
Thanks for that Mark. Unfortunately i've already got quite a sizeable amount of code based around the WebBrowser control. If I can't find an alternative solution i'll certainly give the Net.WebClient class a go though.
Jonny
|
|
|
|
|
My VB .NET app is causing an unhandled exception. When I look at the exception details, it shows me the hex address where the exception is occurring. How I determine where in my code this is happening given an address?
Thanks
|
|
|
|
|
Look for code that calls a COM object, and set breakpoints to work out which one it is.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
The exception is an "invalid typecast". I'm sure it is in my code. I don't believe it has anything to do with COM. Is there some sort of map file that that I can look at to find the method that contains the offending address.
I don't have the debugger on the target machine. An I'd rather not put it on the target. What if the exception happens out in the field? I'd like to be able to find the problem given the offending address.
|
|
|
|
|
If you have cought an exception, you should look at all the information it contains, by
dumping its ToString() result, not jsut its Message. That will give you, amongst others,
a full stack traceback (including file names and line numbers if it is a debug build
with PDB file available next to the EXE/DLL files).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
No, no, no... My app did not catch the exception. So I don't have any idea where to look in my app. The OS, or whatever catches unhandled exceptions, caught the exception and that dialog tells me the address of the where the exception occurred. Now I'm trying to determine where in my app that address is.
|
|
|
|
|
OK, then I suggest you improve the exception catching in your app:
- add a try-catch in your Main() method;
- handle AppDomain.CurrentDomain.UnhandledException event;
- and handle Application.ThreadException event.
Doing all this, you should catch everything except maybe a few drag exceptions.
For each of them, you could do a MessageBox.Show(...Excecption.ToString()...);
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Should be obvious, but what's the best way to find in a datatable the row index where Column C has Value "X"?
Thanks
|
|
|
|
|
Hi,
Dim sql as String = "SELECT ID FROM TABLENAME WHERE C = 'X'"
Dim cmd as New SQLCommand(sql, connectionstring)
... open connection...
Dim idx as integer = CInt(cmd.ExecuteScalar)
Msgbox idx.ToString
hope this helps
|
|
|
|