I'm a little unclear how to syntax the "cancel" button so that it, obviously cancels but also closes the current form window.

My main form has a couple of buttons, when you select one it opens a new window with some selecting options. (Which I'm still working on) Of course I want a cancel button, and for it to work. I know I need an if statement to cancel out of the loop, but I'm not sure how to syntax this portion.

Here's the section of code:
code:
Function cmdGet_List()
Dim $Wait
$Wait = CreateObject("Kixtart.FORM")
$Wait.CAPTION = "Select a Target"
$Wait.SCALEWIDTH = 200
$Wait.SCALEHEIGHT = 250
$Wait.FONTSIZE = 12
$Wait.FONTNAME = "Arial"
$Wait.PrintXY(20,20,"Select Computer Type")
$Wait.CENTER

$Corporate = $Wait.OptionButton
$Corporate.FONTSIZE = 11
$Corporate.FONTNAME = "Arial"
$Corporate.Caption = "Corporate"
$Corporate.Left = 45
$Corporate.Top = 50
$Corporate.Width = 100
$Corporate.Height = 25

$Stores = $Wait.OptionButton
$Stores.Caption = "Stores"
$Stores.Left = 45
$Stores.Top = 80
$Stores.Width = 100
$Stores.Height = 25

$All = $Wait.OptionButton
$All.Caption = "All Units"
$All.Left = 45
$All.Top = 110
$All.Width = 100
$All.Height = 25

$Failed = $Wait.OptionButton
$Failed.Caption = "Failed List"
$Failed.Left = 45
$Failed.Top = 140
$Failed.Width = 130
$Failed.Height = 25

$Button2 = $Wait.CommandButton("Ok")
$Button2.Left = 25
$Button2.Top = 205
$Button2.Width = 50
$Button2.Height = 25

$Button3 = $Wait.CommandButton("Cancel")
$Button3.Left = 105
$Button3.Top = 205
$Button3.Width = 75
$Button3.Height = 25
$Button3.OnClick = 0

$Wait.Show
$FORM.Refresh
While $Wait.Visible
$=Execute($Wait.DoEvents)
Loop
EndFunction

Any Suggestions? [Big Grin] [Big Grin]
_________________________
penny = the target the playing field = three football fields side by side you = only allowed to stand on the outside of the playing field tool you get to use to find the penny = a ONE INCH LAWN DART get the level of difficulty?