home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 5_2007-2008.ISO / data / Zips / Mileage_Lo2070316112007.psc / Form1.frm < prev   
Text File  |  2007-06-10  |  33KB  |  1,038 lines

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
  3. Begin VB.Form Form1 
  4.    Caption         =   "Daily Business and Personal Mileage Log"
  5.    ClientHeight    =   10065
  6.    ClientLeft      =   60
  7.    ClientTop       =   450
  8.    ClientWidth     =   14520
  9.    Icon            =   "Form1.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   10065
  12.    ScaleWidth      =   14520
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.CommandButton Command1 
  15.       BackColor       =   &H00C0FFFF&
  16.       Caption         =   "Calculate Miles Per Gallon"
  17.       Height          =   600
  18.       Left            =   4245
  19.       Style           =   1  'Graphical
  20.       TabIndex        =   29
  21.       Top             =   9255
  22.       Width           =   1515
  23.    End
  24.    Begin VB.Timer Timer1 
  25.       Interval        =   250
  26.       Left            =   4050
  27.       Top             =   8250
  28.    End
  29.    Begin VB.CommandButton cmdPrint 
  30.       BackColor       =   &H00FFC0C0&
  31.       Caption         =   "Show Print Form"
  32.       Height          =   600
  33.       Left            =   6630
  34.       Style           =   1  'Graphical
  35.       TabIndex        =   20
  36.       Top             =   9255
  37.       Width           =   1800
  38.    End
  39.    Begin VB.CommandButton cmdEraseAll 
  40.       BackColor       =   &H00C0FFC0&
  41.       Caption         =   "          Erase all          ( Start New Month)"
  42.       Height          =   585
  43.       Left            =   11400
  44.       Style           =   1  'Graphical
  45.       TabIndex        =   19
  46.       Top             =   9270
  47.       Width           =   1650
  48.    End
  49.    Begin VB.CommandButton cmdEditUpdate 
  50.       BackColor       =   &H008080FF&
  51.       Caption         =   "Update"
  52.       Height          =   600
  53.       Left            =   9255
  54.       Style           =   1  'Graphical
  55.       TabIndex        =   16
  56.       Top             =   9255
  57.       Visible         =   0   'False
  58.       Width           =   1140
  59.    End
  60.    Begin VB.TextBox txtTripMiles 
  61.       Alignment       =   2  'Center
  62.       Appearance      =   0  'Flat
  63.       Height          =   300
  64.       Left            =   7050
  65.       Locked          =   -1  'True
  66.       TabIndex        =   15
  67.       Top             =   8865
  68.       Width           =   1530
  69.    End
  70.    Begin VB.TextBox txtMonYear 
  71.       Alignment       =   2  'Center
  72.       Appearance      =   0  'Flat
  73.       BeginProperty Font 
  74.          Name            =   "MS Sans Serif"
  75.          Size            =   9.75
  76.          Charset         =   0
  77.          Weight          =   700
  78.          Underline       =   0   'False
  79.          Italic          =   0   'False
  80.          Strikethrough   =   0   'False
  81.       EndProperty
  82.       Height          =   315
  83.       Left            =   810
  84.       TabIndex        =   13
  85.       Top             =   9675
  86.       Width           =   1830
  87.    End
  88.    Begin VB.TextBox txtDate 
  89.       Alignment       =   2  'Center
  90.       Appearance      =   0  'Flat
  91.       Height          =   300
  92.       Left            =   0
  93.       TabIndex        =   0
  94.       Top             =   8865
  95.       Width           =   1500
  96.    End
  97.    Begin VB.CommandButton cmdClear 
  98.       BackColor       =   &H000000FF&
  99.       Caption         =   "Delete Selected Item"
  100.       Height          =   600
  101.       Left            =   13170
  102.       Style           =   1  'Graphical
  103.       TabIndex        =   12
  104.       Top             =   9255
  105.       Width           =   1260
  106.    End
  107.    Begin VB.TextBox txtNotes 
  108.       Appearance      =   0  'Flat
  109.       Height          =   300
  110.       Left            =   11610
  111.       TabIndex        =   6
  112.       Top             =   8865
  113.       Width           =   2895
  114.    End
  115.    Begin VB.TextBox txtPM 
  116.       Alignment       =   2  'Center
  117.       Appearance      =   0  'Flat
  118.       Height          =   300
  119.       Left            =   10095
  120.       TabIndex        =   5
  121.       Top             =   8865
  122.       Width           =   1515
  123.    End
  124.    Begin VB.TextBox txtBM 
  125.       Alignment       =   2  'Center
  126.       Appearance      =   0  'Flat
  127.       Height          =   300
  128.       Left            =   8580
  129.       TabIndex        =   4
  130.       Top             =   8865
  131.       Width           =   1515
  132.    End
  133.    Begin VB.TextBox txtStop 
  134.       Alignment       =   2  'Center
  135.       Appearance      =   0  'Flat
  136.       Height          =   300
  137.       Left            =   5505
  138.       TabIndex        =   3
  139.       Top             =   8865
  140.       Width           =   1545
  141.    End
  142.    Begin VB.TextBox txtStart 
  143.       Alignment       =   2  'Center
  144.       Appearance      =   0  'Flat
  145.       Height          =   300
  146.       Left            =   4005
  147.       TabIndex        =   2
  148.       Top             =   8865
  149.       Width           =   1500
  150.    End
  151.    Begin VB.TextBox txtBP 
  152.       Alignment       =   2  'Center
  153.       Appearance      =   0  'Flat
  154.       Height          =   300
  155.       Left            =   1500
  156.       TabIndex        =   1
  157.       Top             =   8865
  158.       Width           =   2505
  159.    End
  160.    Begin MSFlexGridLib.MSFlexGrid Grid1 
  161.       Height          =   8175
  162.       Left            =   0
  163.       TabIndex        =   7
  164.       Top             =   0
  165.       Width           =   14520
  166.       _ExtentX        =   25612
  167.       _ExtentY        =   14420
  168.       _Version        =   393216
  169.       Rows            =   34
  170.       Cols            =   8
  171.       FixedCols       =   0
  172.       BackColorSel    =   16761024
  173.       FocusRect       =   0
  174.       SelectionMode   =   1
  175.       BorderStyle     =   0
  176.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  177.          Name            =   "MS Sans Serif"
  178.          Size            =   8.25
  179.          Charset         =   0
  180.          Weight          =   400
  181.          Underline       =   0   'False
  182.          Italic          =   0   'False
  183.          Strikethrough   =   0   'False
  184.       EndProperty
  185.    End
  186.    Begin VB.Label Label15 
  187.       Caption         =   "Notes"
  188.       BeginProperty Font 
  189.          Name            =   "MS Sans Serif"
  190.          Size            =   8.25
  191.          Charset         =   0
  192.          Weight          =   700
  193.          Underline       =   0   'False
  194.          Italic          =   0   'False
  195.          Strikethrough   =   0   'False
  196.       EndProperty
  197.       Height          =   180
  198.       Left            =   11895
  199.       TabIndex        =   28
  200.       Top             =   8565
  201.       Width           =   570
  202.    End
  203.    Begin VB.Label Label14 
  204.       Caption         =   "Personel Miles"
  205.       BeginProperty Font 
  206.          Name            =   "MS Sans Serif"
  207.          Size            =   8.25
  208.          Charset         =   0
  209.          Weight          =   700
  210.          Underline       =   0   'False
  211.          Italic          =   0   'False
  212.          Strikethrough   =   0   'False
  213.       EndProperty
  214.       Height          =   180
  215.       Left            =   10140
  216.       TabIndex        =   27
  217.       Top             =   8565
  218.       Width           =   1350
  219.    End
  220.    Begin VB.Label Label13 
  221.       Caption         =   "Business Miles"
  222.       BeginProperty Font 
  223.          Name            =   "MS Sans Serif"
  224.          Size            =   8.25
  225.          Charset         =   0
  226.          Weight          =   700
  227.          Underline       =   0   'False
  228.          Italic          =   0   'False
  229.          Strikethrough   =   0   'False
  230.       EndProperty
  231.       Height          =   225
  232.       Left            =   8625
  233.       TabIndex        =   26
  234.       Top             =   8565
  235.       Width           =   1290
  236.    End
  237.    Begin VB.Label Label12 
  238.       Caption         =   "Miles this trip"
  239.       BeginProperty Font 
  240.          Name            =   "MS Sans Serif"
  241.          Size            =   8.25
  242.          Charset         =   0
  243.          Weight          =   700
  244.          Underline       =   0   'False
  245.          Italic          =   0   'False
  246.          Strikethrough   =   0   'False
  247.       EndProperty
  248.       Height          =   225
  249.       Left            =   7170
  250.       TabIndex        =   25
  251.       Top             =   8565
  252.       Width           =   1350
  253.    End
  254.    Begin VB.Label Label11 
  255.       Caption         =   "Ending"
  256.       BeginProperty Font 
  257.          Name            =   "MS Sans Serif"
  258.          Size            =   8.25
  259.          Charset         =   0
  260.          Weight          =   700
  261.          Underline       =   0   'False
  262.          Italic          =   0   'False
  263.          Strikethrough   =   0   'False
  264.       EndProperty
  265.       Height          =   195
  266.       Left            =   5970
  267.       TabIndex        =   24
  268.       Top             =   8565
  269.       Width           =   705
  270.    End
  271.    Begin VB.Label Label10 
  272.       Caption         =   "Start"
  273.       BeginProperty Font 
  274.          Name            =   "MS Sans Serif"
  275.          Size            =   8.25
  276.          Charset         =   0
  277.          Weight          =   700
  278.          Underline       =   0   'False
  279.          Italic          =   0   'False
  280.          Strikethrough   =   0   'False
  281.       EndProperty
  282.       Height          =   210
  283.       Left            =   4560
  284.       TabIndex        =   23
  285.       Top             =   8565
  286.       Width           =   465
  287.    End
  288.    Begin VB.Label Label9 
  289.       Caption         =   "Business Purpose"
  290.       BeginProperty Font 
  291.          Name            =   "MS Sans Serif"
  292.          Size            =   8.25
  293.          Charset         =   0
  294.          Weight          =   700
  295.          Underline       =   0   'False
  296.          Italic          =   0   'False
  297.          Strikethrough   =   0   'False
  298.       EndProperty
  299.       Height          =   240
  300.       Left            =   1995
  301.       TabIndex        =   22
  302.       Top             =   8565
  303.       Width           =   1590
  304.    End
  305.    Begin VB.Label Label8 
  306.       Caption         =   "Date"
  307.       BeginProperty Font 
  308.          Name            =   "MS Sans Serif"
  309.          Size            =   8.25
  310.          Charset         =   0
  311.          Weight          =   700
  312.          Underline       =   0   'False
  313.          Italic          =   0   'False
  314.          Strikethrough   =   0   'False
  315.       EndProperty
  316.       Height          =   180
  317.       Left            =   495
  318.       TabIndex        =   21
  319.       Top             =   8565
  320.       Width           =   495
  321.    End
  322.    Begin VB.Label Label7 
  323.       Caption         =   "Enter data here. ( Use Enter bar only)"
  324.       BeginProperty Font 
  325.          Name            =   "MS Sans Serif"
  326.          Size            =   9.75
  327.          Charset         =   0
  328.          Weight          =   700
  329.          Underline       =   0   'False
  330.          Italic          =   0   'False
  331.          Strikethrough   =   0   'False
  332.       EndProperty
  333.       Height          =   255
  334.       Left            =   45
  335.       TabIndex        =   18
  336.       Top             =   8220
  337.       Width           =   3870
  338.    End
  339.    Begin VB.Label Label6 
  340.       Caption         =   "Edit Mode :Double click on the line                     you want to edit."
  341.       ForeColor       =   &H000000FF&
  342.       Height          =   405
  343.       Left            =   11895
  344.       TabIndex        =   17
  345.       Top             =   8235
  346.       Width           =   2580
  347.    End
  348.    Begin VB.Shape Shape1 
  349.       BackStyle       =   1  'Opaque
  350.       FillColor       =   &H00FFC0C0&
  351.       FillStyle       =   0  'Solid
  352.       Height          =   420
  353.       Left            =   0
  354.       Top             =   8805
  355.       Width           =   14535
  356.    End
  357.    Begin VB.Label Label1 
  358.       Caption         =   "Current Date...retype to change."
  359.       BeginProperty Font 
  360.          Name            =   "MS Sans Serif"
  361.          Size            =   9.75
  362.          Charset         =   0
  363.          Weight          =   700
  364.          Underline       =   0   'False
  365.          Italic          =   0   'False
  366.          Strikethrough   =   0   'False
  367.       EndProperty
  368.       Height          =   240
  369.       Left            =   150
  370.       TabIndex        =   14
  371.       Top             =   9360
  372.       Width           =   3360
  373.    End
  374.    Begin VB.Label Label5 
  375.       Appearance      =   0  'Flat
  376.       BackColor       =   &H80000005&
  377.       BorderStyle     =   1  'Fixed Single
  378.       Caption         =   "  Monthly Totals"
  379.       BeginProperty Font 
  380.          Name            =   "MS Sans Serif"
  381.          Size            =   9.75
  382.          Charset         =   0
  383.          Weight          =   700
  384.          Underline       =   0   'False
  385.          Italic          =   0   'False
  386.          Strikethrough   =   0   'False
  387.       EndProperty
  388.       ForeColor       =   &H80000008&
  389.       Height          =   285
  390.       Left            =   5025
  391.       TabIndex        =   11
  392.       Top             =   8175
  393.       Width           =   1980
  394.    End
  395.    Begin VB.Label Label4 
  396.       Alignment       =   2  'Center
  397.       Appearance      =   0  'Flat
  398.       BackColor       =   &H80000005&
  399.       BorderStyle     =   1  'Fixed Single
  400.       ForeColor       =   &H80000008&
  401.       Height          =   285
  402.       Left            =   10020
  403.       TabIndex        =   10
  404.       Top             =   8175
  405.       Width           =   1515
  406.    End
  407.    Begin VB.Label Label3 
  408.       Alignment       =   2  'Center
  409.       Appearance      =   0  'Flat
  410.       BackColor       =   &H80000005&
  411.       BorderStyle     =   1  'Fixed Single
  412.       ForeColor       =   &H80000008&
  413.       Height          =   285
  414.       Left            =   8505
  415.       TabIndex        =   9
  416.       Top             =   8175
  417.       Width           =   1515
  418.    End
  419.    Begin VB.Label Label2 
  420.       Alignment       =   2  'Center
  421.       Appearance      =   0  'Flat
  422.       BackColor       =   &H80000005&
  423.       BorderStyle     =   1  'Fixed Single
  424.       ForeColor       =   &H80000008&
  425.       Height          =   285
  426.       Left            =   7005
  427.       TabIndex        =   8
  428.       Top             =   8175
  429.       Width           =   1500
  430.    End
  431. End
  432. Attribute VB_Name = "Form1"
  433. Attribute VB_GlobalNameSpace = False
  434. Attribute VB_Creatable = False
  435. Attribute VB_PredeclaredId = True
  436. Attribute VB_Exposed = False
  437. Option Explicit
  438.  
  439. '*******************************************************************
  440. '**                                Mileage Log
  441. '**                               Version 1.0.2
  442. '**                               By Ken Foster
  443. '**                                 June 2007
  444. '**                     Freeware--- no copyrights claimed
  445. '*******************************************************************
  446. 'Credits to  Jonas Wolz (jwolzvb@yahoo.de) for the clsTablePrint
  447. '=============================================
  448.  
  449. Dim gdArray(271)
  450. Dim EditMode As Boolean
  451. Dim fntOld As StdFont
  452. Dim xxx As Integer     ' used in timer1
  453. Dim yyy As Integer     ' used in timer1
  454.  
  455. Private Sub Command1_Click()
  456.    Form3.Show
  457. End Sub
  458.  
  459. Private Sub Form_Load()
  460.     GridIni
  461.     LoadGrid
  462.     UpdateGrid
  463.     txtMonYear.Text = Format(Date, "mmmm  yyyy")
  464.     MSFlexGridColors Grid1, 192, 255, 192      'aternate row colors
  465.     Me.Show                                                 'make sure form is visible
  466.     FormatFlexGrid Grid1         'center data in cells
  467.     NextEmptyLine                  'select first empty line and highlight it
  468.     txtDate.SetFocus               'focus on date window
  469. End Sub
  470.  
  471. Private Sub cmdClear_Click()
  472.     Dim x As Integer
  473.     ClearGridRow
  474.     SaveGrid
  475.     For x = 0 To 271
  476.         gdArray(x) = ""
  477.     Next x
  478.     LoadGrid
  479.     txtDate.SetFocus
  480. End Sub
  481.  
  482. Private Sub cmdEraseAll_Click()
  483. Dim x As Integer
  484. Dim iresp As String
  485.  
  486.     iresp = MsgBox("Are you sure?", vbYesNo, "This will erase everything")
  487.     If iresp = vbNo Then Exit Sub
  488.     For x = 0 To 271
  489.        gdArray(x) = ""
  490.     Next x
  491.     Grid1.Clear
  492.     Label2.Caption = ""
  493.     Label3.Caption = ""
  494.     Label4.Caption = ""
  495.     SaveGrid
  496.     GridIni
  497.     LoadGrid
  498.     MSFlexGridColors Grid1, 192, 255, 192      'aternate row colors
  499.     NextEmptyLine
  500. End Sub
  501.  
  502. Private Sub cmdEditUpdate_Click()
  503.         ' update data to grid
  504.         Grid1.TextMatrix(Grid1.Row, 0) = txtDate.Text
  505.         Grid1.TextMatrix(Grid1.Row, 1) = txtBP.Text
  506.         Grid1.TextMatrix(Grid1.Row, 2) = txtStart.Text
  507.         Grid1.TextMatrix(Grid1.Row, 3) = txtStop.Text
  508.         Grid1.TextMatrix(Grid1.Row, 4) = txtTripMiles.Text
  509.         Grid1.TextMatrix(Grid1.Row, 5) = txtBM.Text
  510.         Grid1.TextMatrix(Grid1.Row, 6) = txtPM.Text
  511.         If txtNotes.Text = "" Then txtNotes.Text = "         "   ' must have something to save here or things get messed up
  512.         Grid1.TextMatrix(Grid1.Row, 7) = txtNotes.Text
  513.         
  514.         'setup for next entry
  515.         ClearTextBoxes
  516.         
  517.         UpdateGrid
  518.         SaveGrid
  519.         LoadGrid
  520.         NextEmptyLine
  521.         'put back into normal mode
  522.         Shape1.FillColor = &HFFC0C0
  523.         Grid1.BackColorSel = &HFFC0C0
  524.         
  525.         cmdEditUpdate.Visible = False
  526.         cmdClear.Enabled = True
  527.         EditMode = False
  528.       
  529. End Sub
  530.  
  531. Private Sub cmdPrint_Click()
  532.    Form2.Show
  533.    If MsgBox("Is the date correct ?", vbYesNo, "Date Correct ?") = vbNo Then
  534.        NextEmptyLine
  535.        txtMonYear.SelStart = Len(txtMonYear.Text)   ' put blinker at end of text
  536.        txtMonYear.SetFocus
  537.        Unload Form2
  538.     End If
  539. End Sub
  540.  
  541. Private Sub Form_Unload(Cancel As Integer)
  542.    Unload Form2
  543.    Unload Me
  544. End Sub
  545.  
  546. Private Sub Grid1_Click()
  547.     'put back into normal mode
  548.         Shape1.FillColor = &HFFC0C0
  549.         Grid1.BackColorSel = &HFFC0C0
  550.         cmdEditUpdate.Visible = False
  551.         cmdClear.Enabled = True
  552.         cmdPrint.Enabled = True
  553.         cmdEraseAll.Enabled = True
  554.         EditMode = False
  555.         'clear everything for next entry
  556.         ClearTextBoxes
  557.         txtDate.SetFocus
  558. End Sub
  559.  
  560. Private Sub Grid1_DblClick()
  561.     If Grid1.TextMatrix(Grid1.Row, 0) = "" Then Exit Sub
  562.     ' you are in edit mode
  563.     cmdEditUpdate.Visible = True
  564.     cmdClear.Enabled = False
  565.     cmdPrint.Enabled = False
  566.     cmdEraseAll.Enabled = False
  567.     EditMode = True
  568.     With Grid1
  569.        Shape1.FillColor = vbRed
  570.        .BackColorSel = vbRed
  571.        
  572.        ' load textboxs for editing
  573.        txtDate.Text = .TextMatrix(.Row, 0)
  574.        txtBP.Text = .TextMatrix(.Row, 1)
  575.        txtStart.Text = .TextMatrix(.Row, 2)
  576.        txtStop.Text = .TextMatrix(.Row, 3)
  577.        txtTripMiles.Text = .TextMatrix(.Row, 4)
  578.        txtBM.Text = .TextMatrix(.Row, 5)
  579.        txtPM.Text = .TextMatrix(.Row, 6)
  580.        txtNotes.Text = .TextMatrix(.Row, 7)
  581.     End With
  582. End Sub
  583.  
  584. Private Sub Timer1_Timer()
  585.    
  586.       If xxx < 3 Then
  587.          Label7.BackColor = vbRed
  588.          xxx = xxx + 1
  589.       Else
  590.          Label7.BackColor = Form1.BackColor
  591.          yyy = yyy + 1
  592.          xxx = 0
  593.       End If
  594.       If yyy = 3 Then Timer1.Enabled = False
  595. End Sub
  596.  
  597. Private Sub txtBM_Click()
  598.     If EditMode = True Then
  599.        txtBM.Text = ""
  600.        txtPM.Text = ""
  601.     End If
  602. End Sub
  603.  
  604. Private Sub txtBM_GotFocus()
  605.    txtBM.BackColor = &HFFF0F0
  606. End Sub
  607.  
  608. Private Sub txtBM_LostFocus()
  609.    txtBM.BackColor = vbWhite
  610. End Sub
  611.  
  612. Private Sub txtBM_KeyPress(KeyAscii As Integer)
  613.     
  614.     If KeyAscii = 13 Then
  615.        If txtBM.Text = "" Then
  616.           txtBM.Text = "     "                                                     'blank fill - keeps things neat and orderly
  617.           txtPM.Text = txtTripMiles.Text
  618.           txtNotes.SetFocus
  619.        Else
  620.          txtPM.Text = Val(txtTripMiles.Text) - Val(txtBM.Text)
  621.          If txtBM.Text = txtTripMiles.Text Then txtPM.Text = "      "   'blank fill
  622.          txtNotes.SetFocus
  623.        End If
  624.     End If
  625.     If InStr(1, "8  48 49 50 51 52 53 54 55 56 57", CStr(KeyAscii)) = 0 Then
  626.         KeyAscii = 0
  627.     End If
  628. End Sub
  629.  
  630. Private Sub txtBP_GotFocus()
  631.    txtBP.BackColor = &HFFF0F0
  632. End Sub
  633.  
  634. Private Sub txtBP_LostFocus()
  635.    txtBP.BackColor = vbWhite
  636. End Sub
  637.  
  638. Private Sub txtBP_KeyPress(KeyAscii As Integer)
  639.     If KeyAscii = 13 Then txtStart.SetFocus
  640. End Sub
  641.  
  642. Private Sub txtDate_GotFocus()
  643.    txtDate.BackColor = &HFFF0F0
  644. End Sub
  645.  
  646. Private Sub txtDate_LostFocus()
  647.    txtDate.BackColor = vbWhite
  648. End Sub
  649.  
  650. Private Sub txtDate_KeyPress(KeyAscii As Integer)
  651.     If KeyAscii = 13 Then txtBP.SetFocus
  652. End Sub
  653.  
  654. Private Sub txtNotes_GotFocus()
  655.    txtNotes.BackColor = &HFFF0F0
  656. End Sub
  657.  
  658. Private Sub txtNotes_LostFocus()
  659.    txtNotes.BackColor = vbWhite
  660. End Sub
  661.  
  662. Private Sub txtNotes_KeyPress(KeyAscii As Integer)
  663.     If KeyAscii = 13 Then
  664.     'put data in the grid
  665.         Grid1.TextMatrix(Grid1.Row, 0) = txtDate.Text
  666.         Grid1.TextMatrix(Grid1.Row, 1) = txtBP.Text
  667.         Grid1.TextMatrix(Grid1.Row, 2) = txtStart.Text
  668.         Grid1.TextMatrix(Grid1.Row, 3) = txtStop.Text
  669.         Grid1.TextMatrix(Grid1.Row, 4) = txtTripMiles.Text
  670.         Grid1.TextMatrix(Grid1.Row, 5) = txtBM.Text
  671.         Grid1.TextMatrix(Grid1.Row, 6) = txtPM.Text
  672.         If txtNotes.Text = "" Then txtNotes.Text = "         "    ' must have something in here to save or things get messed up
  673.         Grid1.TextMatrix(Grid1.Row, 7) = txtNotes.Text
  674.         
  675.         'setup for next entry
  676.         ClearTextBoxes
  677.         
  678.         UpdateGrid
  679.         SaveGrid
  680.         LoadGrid
  681.         
  682.         ' if last entry was in edit mode then set back to normal
  683.         Shape1.FillColor = &HFFC0C0
  684.         Grid1.BackColorSel = &HFFC0C0
  685.         cmdEditUpdate.Visible = False
  686.         cmdClear.Enabled = True
  687.         NextEmptyLine
  688.     End If
  689. End Sub
  690.  
  691. Private Sub txtPM_Click()
  692.     If EditMode = True Then
  693.        txtBM.Text = ""
  694.        txtPM.Text = ""
  695.     End If
  696. End Sub
  697.  
  698. Private Sub txtPM_GotFocus()
  699.    txtPM.BackColor = &HFFF0F0
  700. End Sub
  701.  
  702. Private Sub txtPM_LostFocus()
  703.    txtPM.BackColor = vbWhite
  704. End Sub
  705.  
  706. Private Sub txtPM_KeyPress(KeyAscii As Integer)
  707.     If KeyAscii = 13 Then txtNotes.SetFocus
  708.     If InStr(1, "8  48 49 50 51 52 53 54 55 56 57", CStr(KeyAscii)) = 0 Then KeyAscii = 0
  709. End Sub
  710.  
  711. Private Sub txtStart_Click()
  712.    If EditMode = True Then
  713.        txtStart.Text = ""
  714.        txtStop.Text = ""
  715.        txtTripMiles.Text = ""
  716.        txtBM.Text = ""
  717.        txtPM.Text = ""
  718.     End If
  719. End Sub
  720.  
  721. Private Sub txtStart_GotFocus()
  722.     txtStart.BackColor = &HFFF0F0
  723. End Sub
  724.  
  725. Private Sub txtStart_LostFocus()
  726.    txtStart.BackColor = vbWhite
  727. End Sub
  728.  
  729. Private Sub txtStart_KeyPress(KeyAscii As Integer)
  730.     If KeyAscii = 13 Then txtStop.SetFocus
  731.     If InStr(1, "8  48 49 50 51 52 53 54 55 56 57", CStr(KeyAscii)) = 0 Then KeyAscii = 0
  732. End Sub
  733.  
  734. Private Sub txtStop_Click()
  735.     If EditMode = True Then
  736.        txtStop.Text = ""
  737.        txtTripMiles.Text = ""
  738.        txtBM.Text = ""
  739.        txtPM.Text = ""
  740.     End If
  741. End Sub
  742.  
  743. Private Sub txtStop_GotFocus()
  744.    txtStop.BackColor = &HFFF0F0
  745. End Sub
  746.  
  747. Private Sub txtStop_LostFocus()
  748.    txtStop.BackColor = vbWhite
  749. End Sub
  750.  
  751. Private Sub txtStop_KeyPress(KeyAscii As Integer)
  752.     If KeyAscii = 13 Then
  753.        txtTripMiles.Text = Val(txtStop.Text) - Val(txtStart.Text)
  754.        txtBM.SetFocus
  755.     End If
  756.     If InStr(1, "8  48 49 50 51 52 53 54 55 56 57", CStr(KeyAscii)) = 0 Then KeyAscii = 0
  757. End Sub
  758.  
  759. Private Sub LoadGrid()
  760.     Dim x As Integer
  761.     Dim Y As Integer
  762.     Dim z As Integer
  763.     Dim File As Integer
  764.     Dim instring As String
  765.     Dim FileName As String
  766.     Dim P As Integer
  767.     
  768.     P = 0
  769.     FileName = App.Path & "\" & "DataList.txt"
  770.     On Error GoTo Clnup
  771.     File = FreeFile
  772.     Open FileName For Input As #File ' file opened for reading
  773.     Line Input #File, instring
  774.     'load the array
  775.     gdArray(0) = instring
  776.     While Not EOF(File)
  777.         Line Input #File, instring
  778.         P = P + 1
  779.         gdArray(P) = instring
  780.         Wend
  781.         Close #File
  782.         'load the grid
  783.         For x = 1 To 33
  784.             For Y = 0 To 7
  785.                 Grid1.TextMatrix(x, Y) = gdArray(z)
  786.                 z = z + 1
  787.             Next Y
  788.         Next x
  789.  
  790. Clnup:
  791.         Close #File
  792.     End Sub
  793.  
  794. Private Sub SaveGrid()
  795.     Dim x As Integer
  796.     Dim Y As Integer
  797.     Dim Strg As String
  798.     Dim FileName As String
  799.     Dim ff As Integer
  800.     
  801.     For x = 1 To 33
  802.         For Y = 0 To 7
  803.             If Grid1.TextMatrix(x, Y) = "" Then GoTo here          'don't save empty lines
  804.             Strg = Strg & Grid1.TextMatrix(x, Y) & vbNewLine    ' create the string to save
  805. here:
  806.         Next Y
  807.     Next x
  808.     On Error GoTo Handle
  809.     
  810.     ff = FreeFile
  811.     FileName = App.Path & "\" & "DataList.txt"
  812.     Open FileName For Output As #ff
  813.     Print #ff, Strg
  814.     Close #ff
  815.     Exit Sub
  816. Handle:
  817.     
  818.     MsgBox "Error " & Err.Number & vbCrLf & Err.Description, vbCritical, "Error"
  819. End Sub
  820.  
  821. Private Sub UpdateGrid()
  822.     Dim x As Integer
  823.     'make sure labels are empty before loading them up
  824.     Label2.Caption = ""
  825.     Label3.Caption = ""
  826.     Label4.Caption = ""
  827.     For x = 1 To 33
  828.         Label2.Caption = Val(Label2.Caption) + Val(Grid1.TextMatrix(x, 4))
  829.         Label3.Caption = Val(Label3.Caption) + Val(Grid1.TextMatrix(x, 5))
  830.         Label4.Caption = Val(Label4.Caption) + Val(Grid1.TextMatrix(x, 6))
  831.     Next x
  832.     If Label2.Caption = "0" Then Label2.Caption = ""
  833.     If Label3.Caption = "0" Then Label3.Caption = ""
  834.     If Label4.Caption = "0" Then Label4.Caption = ""
  835.     
  836. End Sub
  837.  
  838. Private Sub ClearGridRow()
  839.     Dim x As Integer
  840.     For x = 0 To 7                                      'clear the selected row
  841.         Grid1.TextMatrix(Grid1.Row, x) = ""
  842.     Next x
  843.     UpdateGrid
  844.     SaveGrid
  845.     'clear everything for next entry
  846.     ClearTextBoxes
  847. End Sub
  848.  
  849. Private Sub MSFlexGridColors(ColorGrid As MSFlexGrid, R As Integer, G As Integer, B As Integer)
  850. ' alternates row colors
  851. Dim j As Integer
  852. Dim i As Integer
  853.     For j = 0 To ColorGrid.Cols - 1
  854.         For i = 1 To ColorGrid.Rows - 1
  855.             If i / 2 <> Int(i / 2) Then
  856.                 ColorGrid.Col = j
  857.                 ColorGrid.Row = i
  858.                 ColorGrid.CellBackColor = RGB(R, G, B)
  859.             End If
  860.         Next i
  861.     Next j
  862. End Sub
  863.  
  864. Public Sub NextEmptyLine()
  865. 'looks for first empty line and selects it
  866. Dim x As Integer
  867.     For x = 1 To 33
  868.        If Grid1.TextMatrix(x, 0) = "" Then
  869.          Grid1.Row = x
  870.          Grid1.Col = 0
  871.          Grid1.SetFocus
  872.          Grid1.ColSel = 7
  873.          txtDate.SetFocus
  874.          Exit Sub
  875.        End If
  876.     Next x
  877. End Sub
  878.  
  879. Public Function FormatFlexGrid(FlexGrid As MSFlexGrid)
  880. 'centers data in cells
  881. Dim i As Integer
  882.     For i = 0 To FlexGrid.Cols - 1
  883.         FlexGrid.ColAlignment(i) = 4   ' 4 = flexaligncenter 8 = right 0 = Left
  884.     Next
  885. End Function
  886.  
  887. Private Sub ClearTextBoxes()
  888.         txtDate.Text = ""
  889.         txtBP.Text = ""
  890.         txtStart.Text = ""
  891.         txtStop.Text = ""
  892.         txtTripMiles.Text = ""
  893.         txtBM.Text = ""
  894.         txtPM.Text = ""
  895.         txtNotes.Text = ""
  896. End Sub
  897.  
  898. Private Sub GridIni()
  899.     Grid1.ColWidth(0) = 1500
  900.     txtDate.Width = Grid1.ColWidth(0)
  901.     'txtDate.Left = Grid1.ColPos(0)
  902.     Grid1.TextMatrix(0, 0) = " Date "
  903.     Grid1.ColWidth(1) = 2500
  904.     txtBP.Width = Grid1.ColWidth(1)
  905.     txtBP.Left = Grid1.ColPos(1) + 7
  906.     Grid1.TextMatrix(0, 1) = "Business Purpose"
  907.     Grid1.ColWidth(2) = 1500
  908.     txtStart.Width = Grid1.ColWidth(2)
  909.     txtStart.Left = Grid1.ColPos(2)
  910.     Grid1.TextMatrix(0, 2) = "Start"
  911.     Grid1.ColWidth(3) = 1500
  912.     txtStop.Width = Grid1.ColWidth(3)
  913.     txtStop.Left = Grid1.ColPos(3)
  914.     Grid1.TextMatrix(0, 3) = "Ending"
  915.     Grid1.ColWidth(4) = 1500
  916.     txtTripMiles.Width = Grid1.ColWidth(4)
  917.     txtTripMiles.Left = Grid1.ColPos(4)
  918.     Grid1.TextMatrix(0, 4) = "Miles this Trip"
  919.     Grid1.ColWidth(5) = 1500
  920.     txtBM.Width = Grid1.ColWidth(5)
  921.     txtBM.Left = Grid1.ColPos(5)
  922.     Grid1.TextMatrix(0, 5) = "Business Miles"
  923.     Grid1.ColWidth(6) = 1500
  924.     txtPM.Width = Grid1.ColWidth(6)
  925.     txtPM.Left = Grid1.ColPos(6)
  926.     Grid1.TextMatrix(0, 6) = "Personal Miles"
  927.     Grid1.ColWidth(7) = 3000
  928.     txtNotes.Width = Grid1.ColWidth(7)
  929.     txtNotes.Left = Grid1.ColPos(7)
  930.     Grid1.TextMatrix(0, 7) = "Notes"
  931.     Shape1.Width = Form1.Width
  932.     Label2.Left = Grid1.ColPos(4)
  933.     Label2.Width = Grid1.ColWidth(4)
  934.     Label3.Left = Grid1.ColPos(5)
  935.     Label3.Width = Grid1.ColWidth(5)
  936.     Label4.Left = Grid1.ColPos(6)
  937.     Label4.Width = Grid1.ColWidth(6)
  938.     Label5.Left = Label2.Left - Label5.Width
  939. End Sub
  940.  
  941. Public Sub ImportFlexGrid(clsTP As clsTablePrint, flxGrd As MSFlexGrid, Optional ByVal sngDesiredWidth As Single = -1)
  942.     Dim lRow As Long, lCol As Long
  943.     Dim sngFXGGesWidth As Single
  944.     
  945.     clsTP.Rows = flxGrd.Rows - flxGrd.FixedRows
  946.     clsTP.Cols = flxGrd.Cols
  947.     clsTP.HeaderRows = flxGrd.FixedRows
  948.     clsTP.HasFooter = False
  949.     clsTP.LineThickness = flxGrd.GridLineWidth
  950.     'Use double line width
  951.     clsTP.HeaderLineThickness = 2 * clsTP.LineThickness
  952.  
  953.     'Set the row height
  954.     clsTP.RowHeightMin = flxGrd.RowHeightMin
  955.     clsTP.FooterRowHeightMin = clsTP.RowHeightMin
  956.     clsTP.HeaderRowHeightMin = clsTP.RowHeightMin
  957.     
  958.     'Use some reasonable default values:
  959.     clsTP.CellXOffset = 10
  960.     clsTP.CellYOffset = 30
  961.     clsTP.CenterMergedHeader = False
  962.     clsTP.ResizeCellsToPicHeight = True
  963.     clsTP.PrintHeaderOnEveryPage = True
  964.     
  965.     Set fntOld = New StdFont
  966.     With flxGrd
  967.         sngFXGGesWidth = 0
  968.         For lRow = 0 To .FixedRows - 1
  969.             For lCol = 0 To .Cols - 1
  970.                 .Col = lCol
  971.                 .Row = lRow '+ .FixedRows
  972.                 Set clsTP.HeaderFont(lRow, lCol) = GetGridFont(flxGrd)
  973.                 If (lRow = 0) Then
  974.                     Select Case .FixedAlignment(lCol) '.CellAlignment
  975.                     Case flexAlignLeftTop, flexAlignLeftBottom, flexAlignLeftCenter
  976.                         clsTP.ColAlignment(lCol) = eLeft
  977.                     Case flexAlignRightTop, flexAlignRightBottom, flexAlignRightCenter
  978.                         clsTP.ColAlignment(lCol) = eRight
  979.                     Case flexAlignCenterTop, flexAlignCenterBottom, flexAlignCenterCenter
  980.                         clsTP.ColAlignment(lCol) = eCenter
  981.                     Case flexAlignGeneral 'Always Left here
  982.                         clsTP.ColAlignment(lCol) = eLeft
  983.                     End Select
  984.                     sngFXGGesWidth = sngFXGGesWidth + .ColWidth(lCol)
  985.                 End If
  986.                 clsTP.HeaderText(lRow, lCol) = .Text
  987.             Next
  988.             clsTP.MergeHeaderRow(lRow) = .MergeRow(lRow)
  989.         Next
  990.         For lCol = 0 To .Cols - 1
  991.             For lRow = 0 To .Rows - .FixedRows - 1
  992.                 .Col = lCol
  993.                 .Row = lRow + .FixedRows
  994.                 Set clsTP.FontMatrix(lRow, lCol) = GetGridFont(flxGrd)
  995.                 If Not (.CellPicture Is Nothing) Then
  996.                     If .CellPicture.Handle <> 0 Then
  997.                         Set clsTP.PictureMatrix(lRow, lCol) = .CellPicture
  998.                     End If
  999.                 End If
  1000.                 clsTP.TextMatrix(lRow, lCol) = .Text
  1001.                 If (lCol = 0) Then
  1002.                     clsTP.MergeRow(lRow) = .MergeRow(lRow)
  1003.                 End If
  1004.             Next
  1005.             If sngDesiredWidth > 0 Then
  1006.                 clsTP.ColWidth(lCol) = (.ColWidth(lCol) / sngFXGGesWidth) * sngDesiredWidth
  1007.             Else
  1008.                 clsTP.ColWidth(lCol) = .ColWidth(lCol)
  1009.             End If
  1010.             clsTP.MergeCol(lCol) = .MergeCol(lCol)
  1011.             clsTP.MergeHeaderCol(lCol) = .MergeCol(lCol)
  1012.         Next
  1013.     End With
  1014. End Sub
  1015.  
  1016. 'Helper Function for ImportFlexGrid()
  1017. Private Function GetGridFont(flxGrd As MSFlexGrid) As StdFont
  1018.     Dim bDiff As Boolean
  1019.     
  1020.     If fntOld Is Nothing Then bDiff = True: GoTo DiffCheck
  1021.     'Font styles:
  1022.     bDiff = bDiff Or (flxGrd.CellFontBold <> fntOld.Bold) Or _
  1023.             (flxGrd.CellFontItalic <> fntOld.Italic) Or (flxGrd.CellFontUnderline <> fntOld.Underline) Or _
  1024.             (flxGrd.CellFontStrikeThrough <> fntOld.Strikethrough)
  1025.     'Name:
  1026.     bDiff = bDiff Or (flxGrd.CellFontName <> fntOld.Name)
  1027.     'Size:
  1028.     bDiff = bDiff Or (flxGrd.CellFont    =) = .MergeRow(lRow)
  1029.         0lFont    =) = Diff        0lFont    =)Nso
  1030.      rlMtrikethrou.M.Text =  (flxGrdYxt =  (flxGrca
  1031.           s    0lFont    =         End If
  1032.             clsTP       =   10       =   1ergeCol(lCol)
  1033.                     lCol(lCol)
  1034.         Gure   =         End If
  1035.       fntOld.Bold) Or _  'Font styles:
  1036.     bDiff = bDiffffffffffffffffffYStrikethrough)
  1037.   " As MSFl Orl         End If
  1038.             (