|
-
Dec 19th, 2001, 01:11 AM
#1
Few Questions
How you doing, This is my first post and I have a few questions about VB
1. Is there a way to tell if a program has been unloaded by pressing the 'x' at the top of the screen
2. Can you sort arrays...eg:
Ive got a type:
Public Type something
name as string
num as integer
etc
etc
End Type
And then:
Dim people(0 to 30) as something
I add stuff to that array when something is selected. Name is added but also the order that the thing was selected. Can I then sort the array based on what number is in 'num'
Thanks alot
-
Dec 19th, 2001, 01:18 AM
#2
PowerPoster
1) If it's your program thats bieng unlaoded by the X then you can put:
VB Code:
Private Sub Form_Terminate()
msgbox "Terminated by X"
End Sub
Thats a loose way of doing it i'm sure there's an api call as well!
What part of Oz?
later
b
-
Dec 19th, 2001, 01:21 AM
#3
I live in Sydney
So is the terminate event called when the 'x' is pressed
Thanks alot
-
Dec 19th, 2001, 01:32 AM
#4
Instead of using the Terminate event use the QueryUnload event.
VB Code:
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If UnloadMode = vbFormControlMenu Then
MsgBox "I'm closing because you pressed the 'X' button"
End If
End Sub
By checking the UnloadMode you can determent why the form is unloading.
Other values this argument can get is:
vbFormCode = The Unload statement is invoked from code.
vbAppWindows = The current Microsoft Windows operating environment session is ending.
vbAppTaskManager = The Microsoft Windows Task Manager is closing the application.
vbFormMDIForm = An MDI child form is closing because the MDI form is closing.
vbFormOwner = A form is closing because its owner is closing.
Best regards
-
Dec 19th, 2001, 01:35 AM
#5
-
Dec 19th, 2001, 01:37 AM
#6
Thanks alot
Anyone got an answer for my second question?
-
Dec 19th, 2001, 02:37 AM
#7
Here's a quicksort that's been modified for a UDT:
VB Code:
Private Sub QuicksortUDT(list() As SOMETHING, ByVal min As Integer, ByVal max As Integer)
Dim med_value As SOMETHING
Dim hi As Integer
Dim lo As Integer
Dim i As Integer
' If the list has no more than CutOff elements,
' finish it off with SelectionSort.
If max <= min Then Exit Sub
' Pick the dividing value.
i = Int((max - min + 1) * Rnd + min)
med_value = list(i)
' Swap it to the front.
list(i) = list(min)
lo = min
hi = max
Do
' Look down from hi for a value < med_value.
'COMPARISON
Do While list(hi).num>= med_value.num
hi = hi - 1
If hi <= lo Then Exit Do
Loop
If hi <= lo Then
list(lo).num= med_value.num
Exit Do
End If
' Swap the lo and hi values.
list(lo) = list(hi)
' Look up from lo for a value >= med_value.
lo = lo + 1
'COMPARISON
Do While list(lo).num< med_value.num
lo = lo + 1
If lo >= hi Then Exit Do
Loop
If lo >= hi Then
lo = hi
list(hi).num= med_value.num
Exit Do
End If
' Swap the lo and hi values.
list(hi) = list(lo)
Loop
' Sort the two sublists.
QuicksortUDT list(), min, lo - 1
QuicksortUDT list(), lo + 1, max
End Sub
Hope that helps
- gaffa
-
Dec 19th, 2001, 04:20 AM
#8
You are a legend. Thanks alot
-
Dec 19th, 2001, 04:26 AM
#9
PowerPoster
-----------------------------------------
-RJ
[email protected]
-----------------------------------------
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
|