home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Ulli's_Sud2103312252008.psc / fMain.frm < prev   
Text File  |  2008-02-25  |  53KB  |  1,739 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form fMain 
  4.    BackColor       =   &H00D0D0D0&
  5.    BorderStyle     =   1  'Fest Einfach
  6.    ClientHeight    =   5325
  7.    ClientLeft      =   45
  8.    ClientTop       =   735
  9.    ClientWidth     =   11355
  10.    Icon            =   "fMain.frx":0000
  11.    KeyPreview      =   -1  'True
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   355
  16.    ScaleMode       =   3  'Pixel
  17.    ScaleWidth      =   757
  18.    StartUpPosition =   2  'Bildschirmmitte
  19.    Begin MSComDlg.CommonDialog CDl 
  20.       Left            =   -15
  21.       Top             =   0
  22.       _ExtentX        =   847
  23.       _ExtentY        =   847
  24.       _Version        =   393216
  25.    End
  26.    Begin VB.TextBox txPuz 
  27.       Alignment       =   2  'Zentriert
  28.       Appearance      =   0  '2D
  29.       BackColor       =   &H00C0C0FF&
  30.       BeginProperty Font 
  31.          Name            =   "Arial"
  32.          Size            =   15.75
  33.          Charset         =   0
  34.          Weight          =   700
  35.          Underline       =   0   'False
  36.          Italic          =   0   'False
  37.          Strikethrough   =   0   'False
  38.       EndProperty
  39.       ForeColor       =   &H000000C0&
  40.       Height          =   435
  41.       Index           =   0
  42.       Left            =   345
  43.       MaxLength       =   1
  44.       MousePointer    =   1  'Pfeil
  45.       TabIndex        =   4
  46.       Top             =   570
  47.       Visible         =   0   'False
  48.       Width           =   435
  49.    End
  50.    Begin VB.TextBox txSol 
  51.       Alignment       =   2  'Zentriert
  52.       Appearance      =   0  '2D
  53.       BackColor       =   &H00C0FFC0&
  54.       BeginProperty Font 
  55.          Name            =   "Arial"
  56.          Size            =   15.75
  57.          Charset         =   0
  58.          Weight          =   700
  59.          Underline       =   0   'False
  60.          Italic          =   0   'False
  61.          Strikethrough   =   0   'False
  62.       EndProperty
  63.       ForeColor       =   &H00008000&
  64.       Height          =   435
  65.       Index           =   0
  66.       Left            =   6570
  67.       Locked          =   -1  'True
  68.       MaxLength       =   1
  69.       MousePointer    =   1  'Pfeil
  70.       TabIndex        =   3
  71.       TabStop         =   0   'False
  72.       Top             =   570
  73.       Visible         =   0   'False
  74.       Width           =   435
  75.    End
  76.    Begin VB.CommandButton btSolve 
  77.       Caption         =   ">> Solve >>"
  78.       Default         =   -1  'True
  79.       BeginProperty Font 
  80.          Name            =   "MS Sans Serif"
  81.          Size            =   8.25
  82.          Charset         =   0
  83.          Weight          =   700
  84.          Underline       =   0   'False
  85.          Italic          =   0   'False
  86.          Strikethrough   =   0   'False
  87.       EndProperty
  88.       Height          =   495
  89.       Left            =   5055
  90.       TabIndex        =   2
  91.       TabStop         =   0   'False
  92.       ToolTipText     =   "Solve Puzzle"
  93.       Top             =   2025
  94.       Width           =   1245
  95.    End
  96.    Begin VB.CommandButton btExit 
  97.       Caption         =   "Exit"
  98.       BeginProperty Font 
  99.          Name            =   "MS Sans Serif"
  100.          Size            =   8.25
  101.          Charset         =   0
  102.          Weight          =   700
  103.          Underline       =   0   'False
  104.          Italic          =   0   'False
  105.          Strikethrough   =   0   'False
  106.       EndProperty
  107.       Height          =   480
  108.       Left            =   5070
  109.       TabIndex        =   1
  110.       TabStop         =   0   'False
  111.       Top             =   4665
  112.       Width           =   1245
  113.    End
  114.    Begin VB.CommandButton btClear 
  115.       Caption         =   "<< Clear >>"
  116.       BeginProperty Font 
  117.          Name            =   "MS Sans Serif"
  118.          Size            =   8.25
  119.          Charset         =   0
  120.          Weight          =   700
  121.          Underline       =   0   'False
  122.          Italic          =   0   'False
  123.          Strikethrough   =   0   'False
  124.       EndProperty
  125.       Height          =   495
  126.       Left            =   5055
  127.       TabIndex        =   0
  128.       TabStop         =   0   'False
  129.       ToolTipText     =   "Clear Puzzle and Solution"
  130.       Top             =   945
  131.       Width           =   1245
  132.    End
  133.    Begin VB.Label lbAnimate 
  134.       BackStyle       =   0  'Transparent
  135.       Caption         =   "  Animate  "
  136.       BeginProperty Font 
  137.          Name            =   "Arial"
  138.          Size            =   9
  139.          Charset         =   0
  140.          Weight          =   700
  141.          Underline       =   0   'False
  142.          Italic          =   0   'False
  143.          Strikethrough   =   0   'False
  144.       EndProperty
  145.       Height          =   270
  146.       Left            =   5205
  147.       TabIndex        =   13
  148.       Top             =   1590
  149.       Width           =   915
  150.    End
  151.    Begin VB.Label lbSolved 
  152.       Alignment       =   2  'Zentriert
  153.       BackColor       =   &H00000000&
  154.       BackStyle       =   0  'Transparent
  155.       BorderStyle     =   1  'Fest Einfach
  156.       Caption         =   "Solved"
  157.       BeginProperty Font 
  158.          Name            =   "Arial"
  159.          Size            =   8.25
  160.          Charset         =   0
  161.          Weight          =   700
  162.          Underline       =   0   'False
  163.          Italic          =   0   'False
  164.          Strikethrough   =   0   'False
  165.       EndProperty
  166.       ForeColor       =   &H00008000&
  167.       Height          =   300
  168.       Left            =   5055
  169.       TabIndex        =   12
  170.       Top             =   2655
  171.       Visible         =   0   'False
  172.       Width           =   1230
  173.    End
  174.    Begin VB.Label lbNoSol 
  175.       Alignment       =   2  'Zentriert
  176.       BackColor       =   &H00000000&
  177.       BackStyle       =   0  'Transparent
  178.       BorderStyle     =   1  'Fest Einfach
  179.       Caption         =   "No Solution"
  180.       BeginProperty Font 
  181.          Name            =   "Arial"
  182.          Size            =   8.25
  183.          Charset         =   0
  184.          Weight          =   700
  185.          Underline       =   0   'False
  186.          Italic          =   0   'False
  187.          Strikethrough   =   0   'False
  188.       EndProperty
  189.       ForeColor       =   &H000000C0&
  190.       Height          =   300
  191.       Left            =   5055
  192.       TabIndex        =   11
  193.       Top             =   2655
  194.       Visible         =   0   'False
  195.       Width           =   1230
  196.    End
  197.    Begin VB.Label lbHide 
  198.       BackColor       =   &H00000000&
  199.       BackStyle       =   0  'Transparent
  200.       Caption         =   " Hide"
  201.       BeginProperty Font 
  202.          Name            =   "Arial"
  203.          Size            =   8.25
  204.          Charset         =   0
  205.          Weight          =   700
  206.          Underline       =   0   'False
  207.          Italic          =   0   'False
  208.          Strikethrough   =   0   'False
  209.       EndProperty
  210.       ForeColor       =   &H00008000&
  211.       Height          =   270
  212.       Left            =   10575
  213.       TabIndex        =   10
  214.       ToolTipText     =   "Hide Solution"
  215.       Top             =   210
  216.       Width           =   480
  217.    End
  218.    Begin VB.Image imgMe 
  219.       Height          =   630
  220.       Left            =   5340
  221.       Picture         =   "fMain.frx":08CA
  222.       ToolTipText     =   "Left: Send Mail to Author  Right: Show About"
  223.       Top             =   90
  224.       Width           =   675
  225.    End
  226.    Begin VB.Label lbTime 
  227.       Alignment       =   2  'Zentriert
  228.       BackColor       =   &H00000000&
  229.       BackStyle       =   0  'Transparent
  230.       Height          =   885
  231.       Left            =   4965
  232.       TabIndex        =   7
  233.       Top             =   3195
  234.       Width           =   1410
  235.    End
  236.    Begin VB.Label lb 
  237.       BackColor       =   &H00000000&
  238.       BackStyle       =   0  'Transparent
  239.       Caption         =   "Puzzle"
  240.       BeginProperty Font 
  241.          Name            =   "Arial"
  242.          Size            =   14.25
  243.          Charset         =   0
  244.          Weight          =   700
  245.          Underline       =   0   'False
  246.          Italic          =   0   'False
  247.          Strikethrough   =   0   'False
  248.       EndProperty
  249.       ForeColor       =   &H00000080&
  250.       Height          =   360
  251.       Index           =   0
  252.       Left            =   2085
  253.       TabIndex        =   6
  254.       Top             =   135
  255.       Width           =   945
  256.    End
  257.    Begin VB.Label lb 
  258.       BackColor       =   &H00000000&
  259.       BackStyle       =   0  'Transparent
  260.       Caption         =   "Solution"
  261.       BeginProperty Font 
  262.          Name            =   "Arial"
  263.          Size            =   14.25
  264.          Charset         =   0
  265.          Weight          =   700
  266.          Underline       =   0   'False
  267.          Italic          =   0   'False
  268.          Strikethrough   =   0   'False
  269.       EndProperty
  270.       ForeColor       =   &H00008000&
  271.       Height          =   360
  272.       Index           =   1
  273.       Left            =   8205
  274.       TabIndex        =   5
  275.       Top             =   135
  276.       Width           =   1155
  277.    End
  278.    Begin VB.Shape sh 
  279.       BorderColor     =   &H00000080&
  280.       BorderWidth     =   3
  281.       Height          =   1500
  282.       Index           =   0
  283.       Left            =   330
  284.       Top             =   555
  285.       Width           =   1500
  286.    End
  287.    Begin VB.Shape sh 
  288.       BorderColor     =   &H00000080&
  289.       BorderWidth     =   3
  290.       Height          =   1500
  291.       Index           =   1
  292.       Left            =   330
  293.       Top             =   2040
  294.       Width           =   1500
  295.    End
  296.    Begin VB.Shape sh 
  297.       BorderColor     =   &H00000080&
  298.       BorderWidth     =   3
  299.       Height          =   1500
  300.       Index           =   2
  301.       Left            =   330
  302.       Top             =   3525
  303.       Width           =   1500
  304.    End
  305.    Begin VB.Shape sh 
  306.       BorderColor     =   &H00000080&
  307.       BorderWidth     =   3
  308.       Height          =   1500
  309.       Index           =   3
  310.       Left            =   1815
  311.       Top             =   3525
  312.       Width           =   1500
  313.    End
  314.    Begin VB.Shape sh 
  315.       BorderColor     =   &H00000080&
  316.       BorderWidth     =   3
  317.       Height          =   1500
  318.       Index           =   4
  319.       Left            =   1815
  320.       Top             =   2040
  321.       Width           =   1500
  322.    End
  323.    Begin VB.Shape sh 
  324.       BorderColor     =   &H00000080&
  325.       BorderWidth     =   3
  326.       Height          =   1500
  327.       Index           =   5
  328.       Left            =   1815
  329.       Top             =   555
  330.       Width           =   1500
  331.    End
  332.    Begin VB.Shape sh 
  333.       BorderColor     =   &H00000080&
  334.       BorderWidth     =   3
  335.       Height          =   1500
  336.       Index           =   6
  337.       Left            =   3300
  338.       Top             =   3525
  339.       Width           =   1500
  340.    End
  341.    Begin VB.Shape sh 
  342.       BorderColor     =   &H00000080&
  343.       BorderWidth     =   3
  344.       Height          =   1500
  345.       Index           =   7
  346.       Left            =   3300
  347.       Top             =   2040
  348.       Width           =   1500
  349.    End
  350.    Begin VB.Shape sh 
  351.       BorderColor     =   &H00000080&
  352.       BorderWidth     =   3
  353.       Height          =   1500
  354.       Index           =   8
  355.       Left            =   3300
  356.       Top             =   555
  357.       Width           =   1500
  358.    End
  359.    Begin VB.Shape sh 
  360.       BorderColor     =   &H00000080&
  361.       BorderWidth     =   2
  362.       Height          =   4515
  363.       Index           =   9
  364.       Left            =   315
  365.       Top             =   540
  366.       Width           =   4515
  367.    End
  368.    Begin VB.Shape sh 
  369.       BorderColor     =   &H00008000&
  370.       BorderWidth     =   3
  371.       Height          =   1500
  372.       Index           =   11
  373.       Left            =   9525
  374.       Top             =   555
  375.       Width           =   1500
  376.    End
  377.    Begin VB.Shape sh 
  378.       BorderColor     =   &H00008000&
  379.       BorderWidth     =   3
  380.       Height          =   1500
  381.       Index           =   12
  382.       Left            =   9525
  383.       Top             =   2040
  384.       Width           =   1500
  385.    End
  386.    Begin VB.Shape sh 
  387.       BorderColor     =   &H00008000&
  388.       BorderWidth     =   3
  389.       Height          =   1500
  390.       Index           =   13
  391.       Left            =   9525
  392.       Top             =   3525
  393.       Width           =   1500
  394.    End
  395.    Begin VB.Shape sh 
  396.       BorderColor     =   &H00008000&
  397.       BorderWidth     =   3
  398.       Height          =   1500
  399.       Index           =   14
  400.       Left            =   8040
  401.       Top             =   555
  402.       Width           =   1500
  403.    End
  404.    Begin VB.Shape sh 
  405.       BorderColor     =   &H00008000&
  406.       BorderWidth     =   3
  407.       Height          =   1500
  408.       Index           =   15
  409.       Left            =   8040
  410.       Top             =   2040
  411.       Width           =   1500
  412.    End
  413.    Begin VB.Shape sh 
  414.       BorderColor     =   &H00008000&
  415.       BorderWidth     =   3
  416.       Height          =   1500
  417.       Index           =   16
  418.       Left            =   8040
  419.       Top             =   3525
  420.       Width           =   1500
  421.    End
  422.    Begin VB.Shape sh 
  423.       BorderColor     =   &H00008000&
  424.       BorderWidth     =   3
  425.       Height          =   1500
  426.       Index           =   17
  427.       Left            =   6555
  428.       Top             =   3525
  429.       Width           =   1500
  430.    End
  431.    Begin VB.Shape sh 
  432.       BorderColor     =   &H00008000&
  433.       BorderWidth     =   3
  434.       Height          =   1500
  435.       Index           =   18
  436.       Left            =   6555
  437.       Top             =   2040
  438.       Width           =   1500
  439.    End
  440.    Begin VB.Shape sh 
  441.       BorderColor     =   &H00008000&
  442.       BorderWidth     =   3
  443.       Height          =   1500
  444.       Index           =   19
  445.       Left            =   6555
  446.       Top             =   555
  447.       Width           =   1500
  448.    End
  449.    Begin VB.Label lb 
  450.       BackColor       =   &H00000000&
  451.       BackStyle       =   0  'Transparent
  452.       Caption         =   "Puzzle"
  453.       BeginProperty Font 
  454.          Name            =   "Arial"
  455.          Size            =   14.25
  456.          Charset         =   0
  457.          Weight          =   700
  458.          Underline       =   0   'False
  459.          Italic          =   0   'False
  460.          Strikethrough   =   0   'False
  461.       EndProperty
  462.       ForeColor       =   &H00FFFFFF&
  463.       Height          =   360
  464.       Index           =   2
  465.       Left            =   2070
  466.       TabIndex        =   8
  467.       Top             =   120
  468.       Width           =   945
  469.    End
  470.    Begin VB.Label lb 
  471.       BackColor       =   &H00000000&
  472.       BackStyle       =   0  'Transparent
  473.       Caption         =   "Solution"
  474.       BeginProperty Font 
  475.          Name            =   "Arial"
  476.          Size            =   14.25
  477.          Charset         =   0
  478.          Weight          =   700
  479.          Underline       =   0   'False
  480.          Italic          =   0   'False
  481.          Strikethrough   =   0   'False
  482.       EndProperty
  483.       ForeColor       =   &H00FFFFFF&
  484.       Height          =   360
  485.       Index           =   3
  486.       Left            =   8190
  487.       TabIndex        =   9
  488.       Top             =   120
  489.       Width           =   1155
  490.    End
  491.    Begin VB.Shape sh 
  492.       BorderColor     =   &H00008000&
  493.       BorderWidth     =   2
  494.       Height          =   4515
  495.       Index           =   10
  496.       Left            =   6540
  497.       Top             =   540
  498.       Width           =   4515
  499.    End
  500.    Begin VB.Shape shBg 
  501.       BorderColor     =   &H00808080&
  502.       FillColor       =   &H00E8E8D0&
  503.       FillStyle       =   0  'Ausgefⁿllt
  504.       Height          =   2460
  505.       Left            =   4965
  506.       Top             =   1920
  507.       Visible         =   0   'False
  508.       Width           =   1410
  509.    End
  510.    Begin VB.Menu mnuFile 
  511.       Caption         =   "&File"
  512.       Begin VB.Menu mnuLoad 
  513.          Caption         =   "&Load Puzzle..."
  514.          Shortcut        =   {F5}
  515.       End
  516.       Begin VB.Menu mnuSavePuz 
  517.          Caption         =   "Save &Puzzle As..."
  518.          Shortcut        =   {F6}
  519.       End
  520.       Begin VB.Menu mnuSaveSol 
  521.          Caption         =   "Save &Solution As..."
  522.          Shortcut        =   {F7}
  523.       End
  524.       Begin VB.Menu sep0 
  525.          Caption         =   "-"
  526.       End
  527.       Begin VB.Menu mnuPrintPuz 
  528.          Caption         =   "Print P&uzzle"
  529.          Shortcut        =   ^P
  530.       End
  531.       Begin VB.Menu mnuPrintSol 
  532.          Caption         =   "Print S&olution"
  533.          Shortcut        =   ^S
  534.       End
  535.       Begin VB.Menu sep1 
  536.          Caption         =   "-"
  537.       End
  538.       Begin VB.Menu mnuExit 
  539.          Caption         =   "Exit"
  540.          Shortcut        =   {F3}
  541.       End
  542.    End
  543.    Begin VB.Menu mnuOptions 
  544.       Caption         =   "&Options"
  545.       Begin VB.Menu mnuVoice 
  546.          Caption         =   "Voice"
  547.          Checked         =   -1  'True
  548.       End
  549.       Begin VB.Menu sep4 
  550.          Caption         =   "-"
  551.       End
  552.       Begin VB.Menu mnuAnimate 
  553.          Caption         =   "&Animate"
  554.          Begin VB.Menu mnuAnimSpeed 
  555.             Caption         =   "Off"
  556.             Checked         =   -1  'True
  557.             Index           =   0
  558.          End
  559.          Begin VB.Menu mnuAnimSpeed 
  560.             Caption         =   "Slow"
  561.             Index           =   1
  562.          End
  563.          Begin VB.Menu mnuAnimSpeed 
  564.             Caption         =   "Medium"
  565.             Index           =   2
  566.          End
  567.          Begin VB.Menu mnuAnimSpeed 
  568.             Caption         =   "Fast"
  569.             Index           =   3
  570.          End
  571.       End
  572.       Begin VB.Menu mnuHide 
  573.          Caption         =   "&Hide"
  574.          Shortcut        =   {F9}
  575.       End
  576.       Begin VB.Menu sep2 
  577.          Caption         =   "-"
  578.       End
  579.       Begin VB.Menu mnuClear 
  580.          Caption         =   "&Clear"
  581.          Shortcut        =   ^C
  582.       End
  583.       Begin VB.Menu mnuSolve 
  584.          Caption         =   "&Solve"
  585.       End
  586.    End
  587.    Begin VB.Menu mnuQ 
  588.       Caption         =   "&?"
  589.       Begin VB.Menu mnuAbout 
  590.          Caption         =   "&About"
  591.          Shortcut        =   {F1}
  592.       End
  593.       Begin VB.Menu mnuSendMail 
  594.          Caption         =   "&Send Mail"
  595.          Shortcut        =   {F2}
  596.       End
  597.    End
  598. End
  599. Attribute VB_Name = "fMain"
  600. Attribute VB_GlobalNameSpace = False
  601. Attribute VB_Creatable = False
  602. Attribute VB_PredeclaredId = True
  603. Attribute VB_Exposed = False
  604. Option Explicit
  605.  
  606. Private Declare Sub InitCommonControls Lib "comctl32" () ':) Line inserted by Formatter
  607. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  608. Private Declare Function Beeper Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
  609. Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, ByRef nSize As Long) As Long
  610. Private Declare Function DrawEdge Lib "user32" (ByVal hDC As Long, qRC As tRect, ByVal Edge As Long, ByVal grfFlags As Long) As Long
  611. Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
  612. Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
  613. Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long
  614. Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
  615. Private Declare Function GetFocus Lib "user32" () As Long
  616. Private Declare Function PutFocus Lib "user32" Alias "SetFocus" (ByVal hWnd As Long) As Long
  617. Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
  618. Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
  619. Private Declare Function SetMenuItemInfo Lib "user32" Alias "SetMenuItemInfoA" (ByVal hMenu As Long, ByVal uItem As Long, ByVal ByPos As Long, lpcMenuItemInfo As MENUITEMINFO) As Long
  620.  
  621. Private HscFrequ    As Currency 'high speed counter frequency - using currency type as 64bit-doublelong
  622. Private StartTick   As Currency
  623. Private EndTick     As Currency
  624. Private Correction  As Currency
  625. Private DelayStart  As Currency
  626. Private DelayEnds   As Currency
  627.  
  628. Private Type MENUITEMINFO
  629.     cbSize          As Long
  630.     fMask           As Long
  631.     fType           As Long
  632.     fState          As Long
  633.     wID             As Long
  634.     hSubMenu        As Long
  635.     hbmpChecked     As Long
  636.     hbmpUnchecked   As Long
  637.     dwItemData      As Long
  638.     dwTypeData      As String
  639.     cch             As Long
  640. End Type
  641. Private MII As MENUITEMINFO
  642.  
  643. Private Type tRect
  644.     L       As Long
  645.     t       As Long
  646.     r       As Long
  647.     b       As Long
  648. End Type
  649. Private RECT        As tRect
  650.  
  651. Private Enum ApiConstants
  652.     BDR_RAISEDOUTER = 1
  653.     BDR_SUNKENOUTER = 2
  654.     BDR_RAISEDINNER = 4
  655.     BDR_SUNKENINNER = 8
  656.     BDR_FILLET = BDR_RAISEDOUTER Or BDR_SUNKENINNER
  657.     BDR_RIDGE = BDR_SUNKENOUTER Or BDR_RAISEDINNER
  658.     BDR_RAISED = BDR_RAISEDOUTER Or BDR_RAISEDINNER
  659.     BDR_SUNKEN = BDR_SUNKENOUTER Or BDR_SUNKENINNER
  660.     BF_RECT = 15
  661.     BF_MONO = &H8000
  662.     SW_SHOWNORMAL = 1
  663.     SE_NO_ERROR = 33  'Values below 33 are error returns
  664.     CS_DROPSHADOW = &H20000
  665.     GCL_STYLE = -26
  666.     REALTIME_PRIORITY_CLASS = &H100
  667.     MFS_DEFAULT = &H1000
  668.     MIIM_STATE = 1
  669. End Enum
  670.  
  671. Private Vox             As SpVoice
  672. Attribute Vox.VB_VarHelpID = -1
  673. Private UserName        As String
  674. Private DecSep          As String
  675. Private Done            As Boolean
  676. Private Timeout         As Boolean
  677. Private Animate         As Boolean
  678. Private Internal        As Boolean
  679. Private LastFocus       As Integer
  680. Private PrioClass       As Long
  681. Private Bits(1 To 9)    As Long
  682. Private FirstFree       As Long
  683. Private LastFree        As Long
  684. Private LastHit         As Long
  685. Private PermissionBits  As Long
  686. Private Success         As Long
  687. Private Const Limit     As Long = 999999
  688. Private Const Interval  As Long = -1 + 2 ^ 13 'must be of this form:  -1 + 2 ^ n
  689. Private AnimDiv         As Long
  690. Private i               As Long
  691. Private j               As Long
  692. Private k               As Long
  693. Private Log2            As Double
  694. Private Const Title     As String = "Ulli's Sudoku Solver"
  695.  
  696. Private Function AllAgree(ByVal Cellnumber As Long, ByVal Value As Long) As Boolean
  697.  
  698.   'cross hatching
  699.   'returns true if row, column and block agree with Value to be put into Cell(CellNumber)
  700.  
  701.     If Groups(Cells(Cellnumber).RowNumber).Agree(Value) Then
  702.         If Groups(Cells(Cellnumber).ColumnNumber).Agree(Value) Then
  703.             AllAgree = Groups(Cells(Cellnumber).BlockNumber).Agree(Value)
  704.         End If
  705.     End If
  706.  
  707. End Function
  708.  
  709. Private Sub btClear_Click()
  710.  
  711.   'resets all values
  712.  
  713.     For j = 1 To 81
  714.         With Cells(j - 1)
  715.             .Value = 0
  716.             .Fixed = False
  717.         End With 'CELLS(j
  718.         With txPuz(j)
  719.             .Text = vbNullString
  720.             .ForeColor = txPuz(0).ForeColor
  721.             .BackColor = txPuz(0).BackColor
  722.             .Tag = vbNullString
  723.         End With 'TXPUZ(j)
  724.         With txSol(j)
  725.             .Text = vbNullString
  726.             .ForeColor = txSol(0).ForeColor
  727.             .BackColor = txSol(0).BackColor
  728.         End With 'TXSOL(j)
  729.     Next j
  730.     For j = 0 To 26
  731.         Groups(j).Reset
  732.     Next j
  733.     SetVisibleTo False
  734.     txPuz(1).SetFocus
  735.     Caption = Title
  736.  
  737. End Sub
  738.  
  739. Private Sub btExit_Click()
  740.  
  741.   'good bye
  742.  
  743.     mnuExit_Click
  744.  
  745. End Sub
  746.  
  747. Private Sub btSolve_Click()
  748.  
  749.   'prepares for finding the solution
  750.  
  751.   Dim Timing    As Single
  752.   Dim Res       As String
  753.   Dim Solved    As Boolean
  754.  
  755.     Enabled = False
  756.     SetVisibleTo False
  757.     For i = 1 To 81 'transfer unsolved puzzle to solution
  758.         If Val(txPuz(i)) Then
  759.             txSol(i) = txPuz(i)
  760.             txSol(i).ForeColor = txPuz(i).ForeColor
  761.             txSol(i).BackColor = txPuz(i).BackColor
  762.           Else 'VAL(TXPUZ(I)) = FALSE/0
  763.             txSol(i) = vbNullString
  764.             txSol(i).ForeColor = IIf(lbHide.BorderStyle, txSol(0).BackColor, txSol(0).ForeColor)
  765.             txSol(i).BackColor = txSol(0).BackColor
  766.         End If
  767.     Next i
  768.     lbTime = vbNullString
  769.     Screen.MousePointer = vbHourglass
  770.     DoEvents
  771.  
  772.     'okay, let's try and find a solution...
  773.  
  774.     Rem Indent Begin
  775.         If Complete(, False) Then 'no contradictions and all unique values completed
  776.  
  777.             'clear the tags
  778.             For i = 0 To 80
  779.                 txPuz(i + 1).Tag = vbNullString
  780.             Next i
  781.  
  782.             QueryPerformanceCounter StartTick 'for timimg
  783.  
  784.             'prepare for backtracking
  785.             Done = False
  786.             Timeout = False
  787.             Success = 0
  788.             LastHit = 0
  789.             FirstFree = 0
  790.             LastFree = 80
  791.  
  792.             'recursive backtracking
  793.             Solve FindLeast
  794.  
  795.             QueryPerformanceCounter EndTick 'for timing
  796.  
  797.           Else 'NOT COMPLETE(,...
  798.             EndTick = StartTick + Correction
  799.         End If
  800.     Rem Indent End
  801.  
  802.     '...and now display the results
  803.  
  804.     If Success <= Limit Then
  805.         SetVisibleTo True
  806.         Timing = (EndTick - StartTick - Correction) / HscFrequ * 1000000
  807.  
  808.         If Timeout Then
  809.             lbSolved.Visible = False
  810.             MsgBox "Could not find a solution within reasonable" & vbCrLf & "time -- and I'm pretty sure there is none.", vbQuestion, "Sorry..."
  811.           Else 'Timeout = FALSE/0
  812.             For i = 1 To 81
  813.                 k = Cells(i - 1).Value
  814.                 If k Then 'cell has a value
  815.                     txSol(i) = k 'show solution
  816.                   Else 'cell has no value; exit early 'K = FALSE/0
  817.                     Exit For 'loopávarying i
  818.                 End If
  819.             Next i
  820.             Solved = (i > 80)
  821.             Vox.Skip "Sentence", 10
  822.             If Solved Then
  823.                 lbNoSol.Visible = False
  824.                 Say lbSolved
  825.               Else 'SOLVED = FALSE/0
  826.                 lbSolved.Visible = False
  827.                 Say lbNoSol
  828.             End If
  829.         End If
  830.         DoEvents
  831.  
  832.         'calc timing
  833.         If Animate Then
  834.             Res = "N/A"
  835.           Else 'ANIMATE = FALSE/0
  836.             Select Case Timing
  837.               Case Is >= 1000000
  838.                 Res = Round(Timing / 1000000, 2) & " Sec"
  839.               Case Is >= 1000
  840.                 Res = Round(Timing / 1000, 2) & " mSec"
  841.               Case Else
  842.                 Res = Int(Timing) & " ╡Sec"
  843.             End Select
  844.         End If
  845.         Res = Replace$(Res, DecSep, ".") & ". "
  846.  
  847.         'display timing
  848.         lbTime = "Time" & IIf(Solved, " to solve:", ":") & vbCrLf & _
  849.                  Res & vbCrLf & vbCrLf & _
  850.                  Replace$(Format$(Success, "#,0 Steps"), ".", DecSep)
  851.         lbTime_Click
  852.  
  853.         'reset puzzle
  854.         For i = 1 To 81
  855.             Cells(i - 1).Value = Val(txPuz(i))
  856.         Next i
  857.         Success = 0
  858.         Enabled = True
  859.         txPuz(1).SetFocus
  860.     End If
  861.     Screen.MousePointer = vbDefault
  862.  
  863. End Sub
  864.  
  865. Private Sub Complain(ByVal Index As Long, Text As String)
  866.  
  867.     Beeper 440, 30
  868.     Say Text
  869.     txPuz(Index) = vbNullString
  870.  
  871. End Sub
  872.  
  873. Private Function Complete(Optional ByVal Dependency As Long = 0, Optional ByVal Alarm As Boolean = True) As Boolean
  874.  
  875.   'complete any row, column or block with only one missing number
  876.   'and look for contradictions
  877.  
  878.   Dim Missing   As Double
  879.  
  880.     Complete = True
  881.     i = 0
  882.     Success = 0
  883.     Do
  884.         With Cells(i)
  885.             If .Value = 0 Then
  886.                 j = Groups(.ColumnNumber).PermitPattern And _
  887.                     Groups(.RowNumber).PermitPattern And _
  888.                     Groups(.BlockNumber).PermitPattern
  889.                 If j Then 'has at least one and possibly more possibilities for cells(i)
  890.                     Missing = Log(j) / Log2 'which are they
  891.                     If Missing = Int(Missing) Then 'just one value possible
  892.                         .Value = Missing 'put that in cell
  893.                         .Fixed = .Value 'and make cell fixed
  894.                         With txPuz(i + 1)
  895.                             Internal = True 'inhibit txPuz_Change processing
  896.                             .Text = Missing 'put value into txPuz also
  897.                             .ForeColor = txSol(0).ForeColor 'and color it as solved
  898.                             .BackColor = txSol(0).BackColor
  899.                             Internal = False
  900.                             If Alarm Then
  901.                                 Beeper 2000, 10 'alert user
  902.                                 Alarm = False
  903.                                 .SetFocus
  904.                                 SetCursorPos Left / 15 + .Left + 31, Top / 15 + .Top + 75
  905.                             End If
  906.                             If Dependency Then 'this is a dependency from another cell during user input
  907.                                 .Tag = Dependency 'save that to undo if necessary
  908.                             End If
  909.                         End With 'TXPUZ(I
  910.                         i = 0 'and restart scan
  911.                         Success = 0
  912.                     End If
  913.                   Else 'no value possible for an empty cell - that's a contradiction 'J = FALSE/0
  914.                     Complete = False 'so set to false
  915.                     i = 80 'and exit
  916.                 End If
  917.               Else 'NOT .VALUE...
  918.                 Success = Success + 1 'count solved cells
  919.             End If
  920.         End With 'CELLS(I)
  921.         i = i + 1
  922.     Loop Until i > 80
  923.  
  924. End Function
  925.  
  926. Private Function Contradiction(ByVal Dependency As Long) As Boolean
  927.  
  928.     Contradiction = Not Complete(Dependency)
  929.  
  930. End Function
  931.  
  932. Private Function ConvertForSpeech(ByVal Cellnumber As Long) As String
  933.  
  934.     ConvertForSpeech = ": " & Chr$((Cellnumber - 1) \ 9 + Asc("A")) & ", " & (Cellnumber + 8) Mod 9 + 1 & """"
  935.  
  936. End Function
  937.  
  938. Private Function FindLeast() As Long
  939.  
  940.   'returns the cell with the least number of possible values
  941.  
  942.   'this algorithm was inspired by Derio's sudoku solver. it is slower on easy puzzles but much faster on
  943.   'harder ones. for example the "beast" has unbelievaby improved (from 70 Sec to 122 mSec), more than 600 times.
  944.   'Thanks a lot, Derio!
  945.  
  946.   Dim Pattern   As Long
  947.   Dim CurPermit As Long
  948.   Dim MinPermit As Long
  949.   Dim NewFirst  As Long
  950.   Dim NewLast   As Long
  951.  
  952.     MinPermit = 10  'preset to max + 1
  953.  
  954.     Rem Indent Begin
  955.         'equivalent to a killer heuristic (see wikipedia); the motivation is that a hit last time may still be good
  956.         With Cells(LastHit)
  957.             If .Value = 0 Then 'free cell
  958.  
  959.                 'combined permit pattern
  960.                 Pattern = Groups(.ColumnNumber).PermitPattern And _
  961.                           Groups(.RowNumber).PermitPattern And _
  962.                           Groups(.BlockNumber).PermitPattern
  963.  
  964.                 'count the permission bits
  965.                 CurPermit = 0
  966.                 For k = 1 To 9
  967.                     If Pattern And Bits(k) Then
  968.                         CurPermit = CurPermit + 1
  969.                     End If
  970.                 Next k
  971.  
  972.                 'save if less
  973.                 If CurPermit < MinPermit Then
  974.                     MinPermit = CurPermit
  975.                     PermissionBits = Pattern
  976.                 End If
  977.             End If
  978.         End With 'CELLS(LASTHIT)
  979.     Rem Indent End
  980.  
  981.     '###########################################################################################################
  982.     'un-commenting next line will nullify the effect of the above killer heuristic; try it to see the difference
  983.     'MinPermit = 10
  984.     '###########################################################################################################
  985.  
  986.     'preset range
  987.     NewFirst = 81
  988.     NewLast = -1
  989.  
  990.     'check all free cells to find the one with the least possibilities
  991.     For j = FirstFree To LastFree
  992.         With Cells(j)
  993.             If .Value = 0 Then 'free cell
  994.  
  995.                 'lower and upper limit for next time
  996.                 If j < NewFirst Then
  997.                     NewFirst = j
  998.                 End If
  999.                 NewLast = j
  1000.  
  1001.                 If MinPermit Then '... else skip this: MinPermit is already zero - it cannot get any lower
  1002.                     'combined permit pattern
  1003.                     Pattern = Groups(.ColumnNumber).PermitPattern And _
  1004.                               Groups(.RowNumber).PermitPattern And _
  1005.                               Groups(.BlockNumber).PermitPattern
  1006.  
  1007.                     'count the permission bits
  1008.                     CurPermit = 0
  1009.                     If Pattern Then '... else nothing to count
  1010.                         For k = 1 To 9
  1011.                             If Pattern And Bits(k) Then
  1012.                                 CurPermit = CurPermit + 1
  1013.                                 If CurPermit >= MinPermit Then 'early out; this will not be considered as good anyway
  1014.                                     Exit For 'loopávarying k
  1015.                                 End If
  1016.                             End If
  1017.                         Next k
  1018.                     End If
  1019.  
  1020.                     'save if less
  1021.                     If CurPermit < MinPermit Then
  1022.                         MinPermit = CurPermit
  1023.                         LastHit = j
  1024.                         PermissionBits = Pattern
  1025.                     End If
  1026.                 End If
  1027.             End If
  1028.  
  1029.         End With 'CELLS(j)
  1030.     Next j
  1031.  
  1032.     'epilog
  1033.     FirstFree = NewFirst
  1034.     LastFree = NewLast
  1035.     FindLeast = LastHit
  1036.     Done = (NewLast = -1) 'ie no free cells
  1037.  
  1038. End Function
  1039.  
  1040. Private Sub Form_Initialize() ':) Line inserted by Formatter
  1041.  
  1042.     InitCommonControls ':) Line inserted by Formatter
  1043.  
  1044. End Sub ':) Line inserted by Formatter
  1045.  
  1046. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  1047.  
  1048.     Select Case KeyCode
  1049.       Case vbKeyEscape
  1050.         btClear.Value = True
  1051.         KeyCode = 0
  1052.       Case vbKeyF3
  1053.         btExit.Value = True
  1054.         KeyCode = 0
  1055.     End Select
  1056.  
  1057. End Sub
  1058.  
  1059. Private Sub Form_Load()
  1060.  
  1061.   Dim CmdParam As String
  1062.  
  1063.     Caption = Title
  1064.  
  1065.     'get user's name
  1066.     i = 128
  1067.     UserName = String$(i, 0)
  1068.     GetUserName UserName, i
  1069.     UserName = Left$(UserName, i + (Asc(Mid$(UserName, i, 1)) = 0))
  1070.     btExit.ToolTipText = "Good Bye, " & UserName
  1071.  
  1072.     'drop a form shadow
  1073.     SetClassLong hWnd, GCL_STYLE, GetClassLong(hWnd, GCL_STYLE) Or CS_DROPSHADOW
  1074.  
  1075.     'prepare for timing measurements
  1076.     QueryPerformanceFrequency HscFrequ
  1077.     QueryPerformanceCounter StartTick
  1078.     QueryPerformanceCounter EndTick
  1079.     Correction = EndTick - StartTick
  1080.  
  1081.     'create all textboxes
  1082.     For i = 1 To 9
  1083.         For j = 1 To 9
  1084.             k = k + 1
  1085.             Load txPuz(k)
  1086.             With txPuz(k)
  1087.                 .Move j * 33 - 10, i * 33 + 5, 32, 32
  1088.                 .Visible = True
  1089.             End With 'TXPUZ(K)
  1090.             Load txSol(k)
  1091.             With txSol(k)
  1092.                 .Move j * 33 + 405, i * 33 + 5, 32, 32
  1093.                 .Visible = True
  1094.             End With 'txSol(K)
  1095.     Next j, i
  1096.  
  1097.     'instantiate and set up the classes
  1098.     For i = 0 To 26
  1099.         Set Groups(i) = New cGroup
  1100.     Next i
  1101.  
  1102.     For i = 0 To 80
  1103.         Set Cells(i) = New cCell
  1104.         With Cells(i)
  1105.             .Cellnumber = i
  1106.         End With 'CELLS(I)
  1107.     Next i
  1108.  
  1109.     With MII 'menu iten info
  1110.         .cbSize = Len(MII)
  1111.         .fMask = MIIM_STATE
  1112.         .fState = MFS_DEFAULT
  1113.         k = GetMenu(hWnd)
  1114.         For i = 0 To 2
  1115.             SetMenuItemInfo k, i, True, MII 'set to bold typeface
  1116.         Next i
  1117.     End With 'MII
  1118.  
  1119.     DecSep = Format$(0, "#.")
  1120.     Log2 = Log(2)
  1121.     For i = 1 To 9
  1122.         Bits(i) = 2 ^ i
  1123.     Next i
  1124.     mnuAnimSpeed_Click 0
  1125.  
  1126.     Set Vox = New SpVoice
  1127.  
  1128.     Select Case True
  1129.       Case InIDE
  1130.         If MsgBox("Compiled Code is a lot faster." & vbCrLf & vbCrLf & "Do you want to run me in the IDE anyway?", vbQuestion Or vbYesNo, Title & " [IDE]") = vbNo Then
  1131.             Unload Me
  1132.         End If
  1133.       Case App.PrevInstance
  1134.         MsgBox Title & " is already loaded.", vbExclamation, "Oops..."
  1135.         Unload Me
  1136.       Case Else
  1137.         Say "Hi " & UserName
  1138.         CmdParam = Replace$(Command$, """", "")
  1139.         If Len(CmdParam) Then
  1140.             LoadPuzzle CmdParam
  1141.             Caption = Title & " [" & Right$(CmdParam, Len(CmdParam) - InStrRev(CmdParam, "\")) & "]"
  1142.         End If
  1143.     End Select
  1144.     mnuVoice_Click
  1145.  
  1146. End Sub
  1147.  
  1148. Private Sub Form_Paint()
  1149.  
  1150.   'draws the frames
  1151.  
  1152.     With RECT
  1153.         For i = 9 To 10
  1154.             .L = sh(i).Left - 7
  1155.             .t = sh(i).Top - 30
  1156.             .r = sh(i).Left + sh(i).Width + 6
  1157.             .b = sh(i).Top + sh(i).Height + 6
  1158.             DrawEdge hDC, RECT, BDR_RAISED, BF_RECT
  1159.             .L = .L + 2
  1160.             .t = .t + 2
  1161.             .r = .r - 2
  1162.             .b = .b - 2
  1163.             DrawEdge hDC, RECT, BDR_RAISEDINNER, BF_RECT
  1164.         Next i
  1165.     End With 'RECT
  1166.  
  1167. End Sub
  1168.  
  1169. Private Sub Form_Unload(Cancel As Integer)
  1170.  
  1171.   'tidy up
  1172.  
  1173.     Success = Limit + 1
  1174.     For i = 0 To 80
  1175.         Set Cells(i) = Nothing
  1176.     Next i
  1177.     For i = 0 To 26
  1178.         Set Groups(i) = Nothing
  1179.     Next i
  1180.     If Not InIDE Then
  1181.         mnuVoice.Checked = True
  1182.         Say "Good bye " & UserName
  1183.         Say vbNullString, True
  1184.     End If
  1185.     Set Vox = Nothing
  1186.     Rem Mark Off Silent
  1187.     End
  1188.     Rem Mark On
  1189.  
  1190. End Sub
  1191.  
  1192. Private Sub imgMe_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1193.  
  1194.     imgMe.BorderStyle = 1
  1195.  
  1196. End Sub
  1197.  
  1198. Private Sub imgMe_Mouseup(Button As Integer, Shift As Integer, x As Single, y As Single)
  1199.  
  1200.     imgMe.BorderStyle = 0
  1201.     With App
  1202.         Select Case Button
  1203.           Case Is = vbLeftButton
  1204.             If ShellExecute(hWnd, vbNullString, "mailto:UMGEDV@Yahoo.com?subject=" & .ProductName & " V" & .Major & "." & .Minor & "." & .Revision & " &body=Hi Ulli,<br><br>[your message]<br><br>Best regards from " & UserName, vbNullString, .Path, SW_SHOWNORMAL) < SE_NO_ERROR Then
  1205.                 MsgBox "Cannot send Mail from this System.", vbCritical, "Mail disabled/not installed"
  1206.             End If
  1207.           Case vbRightButton
  1208.             Load frmAbout
  1209.             With frmAbout
  1210.                 .AppIcon(&HFFE0C0) = Icon
  1211.                 .Title(&HD0D0FF) = Title
  1212.                 .Version(&HF0F0A0) = "Version " & App.Major & "." & App.Minor & "." & App.Revision
  1213.                 .Copyright(vbYellow) = App.LegalCopyright
  1214.                 .Otherstuff1(&HF0FFF0) = "Sudoko Solver using Backtrace and Crosshatching"
  1215.                 .Otherstuff2(&HE0D0D0) = "Least Possibility Cell Selection Algorithm" & vbCrLf & "by Derio"
  1216.                 .Show vbModal, Me
  1217.             End With 'FRMABOUT
  1218.         End Select
  1219.     End With 'APP
  1220.  
  1221. End Sub
  1222.  
  1223. Private Function InIDE(Optional c As Boolean = False) As Boolean
  1224.  
  1225.   Static b  As Boolean
  1226.  
  1227.     b = c
  1228.     If b = False Then
  1229.         Debug.Assert InIDE(True)
  1230.     End If
  1231.     InIDE = b
  1232.  
  1233. End Function
  1234.  
  1235. Private Sub lbAnimate_Click()
  1236.  
  1237.     With lbAnimate
  1238.         .BorderStyle = 1 - .BorderStyle
  1239.         Animate = .BorderStyle
  1240.         mnuAnimSpeed_Click .BorderStyle * 2
  1241.     End With 'LBANIMATE
  1242.     SetVisibleTo False
  1243.  
  1244. End Sub
  1245.  
  1246. Private Sub lbHide_Click()
  1247.  
  1248.   'using a label to avoid difficulties with current focus
  1249.  
  1250.     With lbHide
  1251.         .BorderStyle = 1 - .BorderStyle
  1252.         mnuHide.Checked = .BorderStyle
  1253.         For i = 1 To 81
  1254.             If txSol(i).BackColor = txSol(0).BackColor Then
  1255.                 If .BorderStyle Then
  1256.                     txSol(i).ForeColor = txSol(0).BackColor
  1257.                   Else '.BORDERSTYLE = FALSE/0
  1258.                     txSol(i).ForeColor = txSol(0).ForeColor
  1259.                 End If
  1260.             End If
  1261.         Next i
  1262.         If .BorderStyle Then
  1263.             .ToolTipText = "Show Solution"
  1264.           Else '.BORDERSTYLE = FALSE/0
  1265.             .ToolTipText = "Hide Solution"
  1266.         End If
  1267.     End With 'LBHIDE
  1268.  
  1269. End Sub
  1270.  
  1271. Private Sub lbTime_Click()
  1272.  
  1273.   'needs some modifications to make it understandable
  1274.  
  1275.     Say Replace$(Replace$(lbTime, "╡", "micro "), "N/A", "not applicable."), True
  1276.  
  1277. End Sub
  1278.  
  1279. Private Sub LoadPuzzle(Filename As String)
  1280.  
  1281.   Dim hFile As Long
  1282.   Dim Inp   As String
  1283.  
  1284.     hFile = FreeFile
  1285.     Open Filename For Input As hFile
  1286.     Input #hFile, Inp
  1287.     Close hFile
  1288.     Internal = True
  1289.     For i = 1 To Len(Inp)
  1290.         If i > 81 Then
  1291.             Say "File layout is invalid"
  1292.             Exit For 'loopávarying i
  1293.           Else 'NOT I...
  1294.             If IsNumeric(Mid$(Inp, i, 1)) Then
  1295.                 With Cells(i - 1)
  1296.                     .Value = Mid$(Inp, i, 1)
  1297.                     .Fixed = True
  1298.                     txPuz(i) = .Value
  1299.                 End With 'CELLS(I
  1300.               Else 'NOT ISNUMERIC(MID$(INP,...
  1301.                 txPuz(i) = vbNullString
  1302.             End If
  1303.         End If
  1304.     Next i
  1305.     Internal = False
  1306.  
  1307. End Sub
  1308.  
  1309. Private Sub mnuAbout_Click()
  1310.  
  1311.     imgMe_Mouseup vbRightButton, 0, 0, 0
  1312.  
  1313. End Sub
  1314.  
  1315. Private Sub mnuAnimSpeed_Click(Index As Integer)
  1316.  
  1317.     For k = 0 To 3
  1318.         mnuAnimSpeed(k).Checked = (k = Index)
  1319.     Next k
  1320.     Select Case Index
  1321.       Case 1
  1322.         AnimDiv = 3
  1323.       Case 0, 2
  1324.         AnimDiv = 10
  1325.       Case 3
  1326.         AnimDiv = 30
  1327.     End Select
  1328.     lbAnimate.BorderStyle = Sgn(Index)
  1329.     Animate = Sgn(Index)
  1330.     lbAnimate.ToolTipText = AnimDiv & " Steps per Second"
  1331.  
  1332. End Sub
  1333.  
  1334. Private Sub mnuClear_Click()
  1335.  
  1336.     btClear.Value = True
  1337.  
  1338. End Sub
  1339.  
  1340. Private Sub mnuExit_Click()
  1341.  
  1342.     Visible = False
  1343.     DoEvents
  1344.     Unload Me
  1345.  
  1346. End Sub
  1347.  
  1348. Private Sub mnuHide_Click()
  1349.  
  1350.     mnuHide.Checked = Not mnuHide.Checked
  1351.     If mnuHide.Checked Then
  1352.         lbHide.BorderStyle = 0
  1353.       Else 'MNUHIDE.CHECKED = FALSE/0
  1354.         lbHide.BorderStyle = 1
  1355.     End If
  1356.     lbHide_Click
  1357.  
  1358. End Sub
  1359.  
  1360. Private Sub mnuLoad_Click()
  1361.  
  1362.     With CDl
  1363.         .InitDir = App.Path
  1364.         .DialogTitle = "Enter/Select file to load..."
  1365.         .Filename = vbNullString
  1366.         .DefaultExt = ".SKP"
  1367.         .Filter = "Sudoku Puzzle (*.SKP)|*.SKP|Sudoku Solution (*.SKS)|*.SKS"
  1368.         .Flags = cdlOFNPathMustExist Or cdlOFNLongNames
  1369.         On Error Resume Next
  1370.             .ShowOpen
  1371.             If Err = 0 Then
  1372.                 btClear.Value = True
  1373.                 LoadPuzzle .Filename
  1374.                 Caption = Title & " [" & CDl.FileTitle & "]"
  1375.             End If
  1376.         On Error GoTo 0
  1377.     End With 'CDL
  1378.  
  1379. End Sub
  1380.  
  1381. Private Sub mnuPrintPuz_Click()
  1382.  
  1383.     PrintIt 1
  1384.  
  1385. End Sub
  1386.  
  1387. Private Sub mnuPrintSol_Click()
  1388.  
  1389.     If lbSolved.Visible = False And lbNoSol.Visible = False Then
  1390.         btSolve_Click
  1391.     End If
  1392.     PrintIt 2
  1393.  
  1394. End Sub
  1395.  
  1396. Private Sub mnuSavePuz_Click()
  1397.  
  1398.     SavePuzzle 0
  1399.  
  1400. End Sub
  1401.  
  1402. Private Sub mnuSaveSol_Click()
  1403.  
  1404.     SavePuzzle 1
  1405.  
  1406. End Sub
  1407.  
  1408. Private Sub mnuSendMail_Click()
  1409.  
  1410.     imgMe_Mouseup vbLeftButton, 0, 0, 0
  1411.  
  1412. End Sub
  1413.  
  1414. Private Sub mnuSolve_Click()
  1415.  
  1416.     btSolve.Value = True
  1417.  
  1418. End Sub
  1419.  
  1420. Private Sub mnuVoice_Click()
  1421.  
  1422.     mnuVoice.Checked = Not mnuVoice.Checked
  1423.  
  1424. End Sub
  1425.  
  1426. Private Sub Printer_DrawBox(Optional ByVal Small As Boolean = True)
  1427.  
  1428.     With RECT
  1429.         If Small Then
  1430.             .L = Printer.CurrentX - Printer.ScaleLeft - 60
  1431.             .t = Printer.CurrentY - 15
  1432.             .b = .t + 225
  1433.             .r = .L + 225
  1434.           Else 'SMALL = FALSE/0
  1435.             .L = Printer.CurrentX - Printer.ScaleLeft - 45
  1436.             .t = Printer.CurrentY + 240
  1437.             .b = .t + 2430
  1438.             .r = .L + 2445
  1439.             DrawEdge Printer.hDC, RECT, BDR_SUNKENOUTER, BF_RECT Or BF_MONO
  1440.             .L = .L - 15
  1441.             .t = .t - 15
  1442.             .b = .b + 15
  1443.             .r = .r + 15
  1444.         End If
  1445.     End With 'RECT
  1446.     DrawEdge Printer.hDC, RECT, BDR_SUNKENOUTER, BF_RECT Or BF_MONO
  1447.  
  1448. End Sub
  1449.  
  1450. Private Sub PrintIt(ByVal Num As Long)
  1451.  
  1452.   Dim t As Boolean
  1453.  
  1454.     With Printer
  1455.         .FontName = txSol(0).FontName
  1456.         .FontSize = txSol(0).FontSize
  1457.         .FontBold = True
  1458.         .ForeColor = vbBlack
  1459.         .ScaleMode = vbPixels
  1460.         .ScaleLeft = 0
  1461.         Printer.Print
  1462.         .CurrentX = (.ScaleWidth - .TextWidth(Caption)) / 2
  1463.         Printer.Print Caption
  1464.  
  1465.         .ScaleLeft = -1200
  1466.  
  1467.         For j = 1 To Num
  1468.             .FontSize = txSol(0).FontSize
  1469.             Printer.Print vbCrLf
  1470.             .ForeColor = vbBlack
  1471.             .FontBold = True
  1472.             If j = 1 Then
  1473.                 Printer.Print ; "Puzzle";
  1474.               Else 'NOT J...
  1475.                 Printer.Print vbCrLf
  1476.                 If lbNoSol.Visible Then
  1477.                     Printer.Print ; "No Solution"
  1478.                     Exit For 'loopávarying j
  1479.                 End If
  1480.                 Printer.Print ; "Solution";
  1481.             End If
  1482.             Printer.Print
  1483.             Printer_DrawBox False
  1484.             .FontSize = 22
  1485.  
  1486.             For i = 1 To 81
  1487.                 If (i Mod 9) = 1 Then
  1488.                     Printer.Print
  1489.                     .CurrentY = .CurrentY + .TextWidth("1") / 2.4
  1490.                 End If
  1491.                 If (i Mod 27) = 1 Then
  1492.                     .CurrentY = .CurrentY + .TextWidth(" ")
  1493.                 End If
  1494.                 If (i Mod 3) = 1 Then
  1495.                     Printer.Print " ";
  1496.                 End If
  1497.                 Printer_DrawBox
  1498.                 .FontBold = (txSol(i).BackColor = txSol(0).BackColor)
  1499.                 .ForeColor = IIf(.FontBold, vbBlack, &H808080)
  1500.                 If j = 1 Then
  1501.                     .FontBold = True
  1502.                     If Num = 1 Then
  1503.                         t = (txPuz(i).BackColor <> txPuz(0).BackColor) Or txPuz(i) = vbNullString
  1504.                       Else 'NOT NUM...
  1505.                         t = (txSol(i).BackColor = txSol(0).BackColor)
  1506.                     End If
  1507.                     If t Then
  1508.                         .ForeColor = vbWhite
  1509.                         Printer.Print "0   ";
  1510.                       Else 'T = FALSE/0
  1511.                         .ForeColor = vbBlack
  1512.                         Printer.Print txPuz(i); "   ";
  1513.                     End If
  1514.                   Else 'NOT J...
  1515.                     Printer.Print txSol(i); "   ";
  1516.                 End If
  1517.             Next i
  1518.         Next j
  1519.         .ScaleLeft = 0
  1520.         .EndDoc
  1521.     End With 'PRINTER
  1522.  
  1523. End Sub
  1524.  
  1525. Private Sub SavePuzzle(ByVal Which As Long)
  1526.  
  1527.   Dim hFile As Long
  1528.   Dim Box   As TextBox
  1529.  
  1530.     With CDl
  1531.         .InitDir = App.Path
  1532.         .DialogTitle = "Enter/Select file to save..."
  1533.         If Which = 1 Then
  1534.             .DefaultExt = ".SKS"
  1535.             .Filter = "Sudoku Solution (*.SKS)|*.SKS"
  1536.           Else 'NOT WHICH...
  1537.             .DefaultExt = ".SKP"
  1538.             .Filter = "Sudoku Puzzle (*.SKP)|*.SKP"
  1539.         End If
  1540.         .Flags = cdlOFNPathMustExist Or cdlOFNLongNames Or cdlOFNOverwritePrompt
  1541.         On Error Resume Next
  1542.             CDl.ShowSave
  1543.             If Err = 0 Then
  1544.                 hFile = FreeFile
  1545.                 Open CDl.Filename For Output As hFile
  1546.                 For k = 1 To 81
  1547.                     If Which = 1 Then
  1548.                         Set Box = txSol(k)
  1549.                       Else 'NOT WHICH...
  1550.                         Set Box = txPuz(k)
  1551.                     End If
  1552.                     If Len(Box) Then
  1553.                         Print #hFile, Box;
  1554.                       Else 'LEN(BOX) = FALSE/0
  1555.                         Print #hFile, "x";
  1556.                     End If
  1557.                 Next k
  1558.                 Close hFile
  1559.             End If
  1560.         On Error GoTo 0
  1561.         .Filename = vbNullString
  1562.     End With 'CDL
  1563.  
  1564. End Sub
  1565.  
  1566. Private Sub Say(Text As String, Optional Wait As Boolean = False)
  1567.  
  1568.     If mnuVoice.Checked Then
  1569.         If Wait Then
  1570.             Vox.WaitUntilDone 99999
  1571.         End If
  1572.         Vox.Speak Text & ".", SVSFlagsAsync
  1573.     End If
  1574.  
  1575. End Sub
  1576.  
  1577. Private Sub SetVisibleTo(Vis As Boolean)
  1578.  
  1579.     lbTime.Visible = Vis
  1580.     lbSolved.Visible = Vis
  1581.     lbNoSol.Visible = Vis
  1582.     shBg.Visible = Vis
  1583.  
  1584. End Sub
  1585.  
  1586. Private Sub ShowCell(ByVal Cellnumber As Long, ByVal Value As Long)
  1587.  
  1588.     QueryPerformanceCounter DelayStart
  1589.     With txSol(Cellnumber + 1)
  1590.         If Value Then
  1591.             .Text = Value
  1592.             DelayStart = DelayStart + HscFrequ / AnimDiv
  1593.           Else 'VALUE = FALSE/0
  1594.             .Text = vbNullString
  1595.             DelayStart = DelayStart + HscFrequ / AnimDiv / 8 'rollback is faster
  1596.         End If
  1597.         .Refresh
  1598.     End With 'TXSOL(CELLNUMBER
  1599.     Do
  1600.         
  1601.         End  End With 'TXSOL(CELL  InIDE(True)
  1602.   fau) ame = vbNullString
  1603.     End IDim Box   As TextBox
  1604.  
  1605. a + Hsc
  1606.  
  1607. a + Hsc
  1608.  Sub
  1609.  
  1610. Priv=c
  1611.  
  1612. a + Hsc
  1613. Hsc9         t = (txSoSKP"
  1614.             .Filter + HshBg.Vi= Icon
  1615.                 .Title(&HD0D0FF) = Title
  1616.                 .Version(&HF0F0A0)String
  1617.     End ItForSemf
  1618.    IFdth - .TEVersion(&HF0F0A0)String
  1619.  uVoice.Checked Then
  1620.         If Wait The
  1621.  
  1622.    ide 
  1623.          
  1624.              I    3============================/ AnfsM9a========/ AnfsM91
  1625.     Loop UntilTipText =. for exSoSKat =.   t = (txSinter.PriOd eftilTipTex        t = (============/ AnfsM9a========/ ApII 'menu iten info
  1626.            DoAuorderStyle = 0
  1627.       EgsAsync
  1628.     Eth 'TXSOL(CELL  InIDE(TSSSSStrin
  1629.  
  1630. Private cfapt
  1631.  
  1632. Private 9i   EnI     .Text =wfoVeith txPuz(j)
  1633.        e
  1634.  
  1635.   =========1Rsibilir2
  1636.                          ilir e
  1637.  
  1638.   =========Rth g
  1639.    
  1640.   ==m+i=====Rth g
  1641.    |     ####        t     mf
  1642.    IFdth - .Tp
  1643.   ceCounter Dex)
  1644.  
  1645. Counti    ine in = vbNullString         minter Dex)
  1646.  
  1647. Coue     CeHICH...
  1648.               I7nuC;+nal Wait As Boolean====CheckThen
  1649.        layStan = bCF/0ixt =. for exSoSKat =.   t = (txor =  'rollback is faster
  1650.     l(i).BackColor 0l Wa(txorEd IfI             Neuz(kait As Boolean====Chring         mintd by Formatte #hFile, Box;
  1651.  b
  1652.     Set Vox = New mir9a========/ ApI(CELLNUMBER
  1653.     D        Neuz(kait As Boolean====Chringssert         Frio!=  Neuz(    t Vox = New mir9atti
  1654.      = NRlback o!=  ipaaon, 0,hriny    
  1655. PriFilenam=====)Striixt =. fam=====)Srnal   t = (txomjriixt =. fam=====)Srnal   t = (txo   Animate = .BorderStyle
  1656.     2 #hFile,  If =====/ ApII 'menu iten info
  1657.            DoAuordjriixt =. fS       .ScaleMod,nal  ex      
  1658. Coue         tet any lower
  1659.  t = (   p Walready loultioSKat ext Rth    
  1660. Coue        ======ilir 'rollback is faster
  1661.     l(iiiiiefre        hFile = FreeFile
  1662.                 Open CDl.Filename For Output A
  1663.     F) = Title
  1664.                 .Version(&HF0sM91
  1665.     Loop UntilTipTeC4 
  1666.     j(t:       .ScaleMod,nal8     Print   lbNoSol.VisibL) < SE_NO_ERROR=uPersion(iit As Integect C(er
  1667.         End If
  1668.         .Refresh
  1669.     End With:d If
  1670.         End If
  1671.     Next i
  1672. EobNoSol.VisibL) < SE_NO_ERROR=uPersion(ii< SE    IDE(TSSSSStrin
  1673.  
  1674. Privat Vox.SVersu / AnimDiv  2s BoopNOT J...
  1675.                     egecPsion(iit As"R
  1676.  
  1677. ]Dir = Apeuz(SE    IDE(TSS,(&HF0F0A0)String Int  e
  1678.  
  1679.   ===
  1680.    L...
  1681. fa     r = vbBlack
  1682.         .ScaleMode = vbPixels
  1683.          e
  1684.  
  1685.  To(Vis As Boolean)
  1686.  
  1687.   ursion(s"Rr"  ==vbPixe        (TSS,l(0).Fontrsion(s"ir = Apeuz(SE    IDE(TSJ)
  1688.         If Value Then
  1689.             .Text = VaTex        t = (========End If
  1690. tX - Printontrsion(s"ir = ApeuzDE(TSamixt =. for ek==m+i To 9e   .Text = VaTex  a(+c1I   End     v  a(+c1I   SSSSSoole  t = c1I D1I D1I D1I D1I D1I D1I Deuz(SEscaovIBEscaove   .TexKtrin
  1691. finter Dex)
  1692.  
  1693. Coue     CeHICH...
  1694. ox   As TTTTTRefr
  1695.  
  1696. a + Hsc
  1697. i   th    
  1698. Coue   LL  InIDE(TSSSSStrin
  1699.  
  1700. PrivadPo   Animate = .BorderStyle
  1701.      As Long
  1702.     bPrinter.Print
  1703.      As"R
  1704. Div  2s BoopNOT J...
  1705.                     et
  1706.      As"R    et
  1707.      As"R    et
  1708.    End If
  1709.     n me[ioePe Sub im0      3========/ ApII 'menu .SSol(0).Font-M Ent
  1710.    Euz(kait As Bi(TSSmnuHidename = vbNullS22'menu .SSol( vbNulWu Puzzle ( Euz
  1711.    E"R
  1712. Div  2NOT I..o'dA fasterPuzzl
  1713.       iI..o'dA fastRDERSTYLE = FALSE/0hAs r
  1714.             .DefaLE = FALSE/0hAs r
  1715. bNulWu PE    IDE(TSS,le = FRDERFth - .TEVersion(&Hle = FRDERFth - .TEVersme = vbNullS22'menu .SS= FALSE/0RDERFt.TEVulWu Puzzle (CrLf
  1716.        = "E   se
  1717.  ah - .Tp
  1718.   e          If (i Mod    .T(ii< SE    IDE(TSSSS"
  1719.                 If (i"
  1720.               As"R    et
  1721.    End IfIf
  1722.     lbHide_Click
  1723.  
  1724. End Sub
  1725.  
  1726. Private Sub mn   nh
  1727.  2, 32
  1728.  t =a    ,          Casetice.C iNext j
  1729. ntBold = True
  1730. n =====i=a    ,bb
  1731. evate Sub mnuSavePuz_Click()
  1732.  
  1733.     SavePenu sA fastRaNO_ERROR=uPersioooo           .r
  1734. ntIf
  1735.   ionnnnnnnnnrsioooo   n ==== =========Rth g
  1736.    E======csSub
  1737. e,  If =====/ AICH...                       Set Box um
  1738.   r
  1739. bNun =====i=a    ,bf................R,bf........=====)Srnal