home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / calendek / calendar.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-03-02  |  23.6 KB  |  778 lines

  1. VERSION 2.00
  2. Begin Form frmDate 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Select Date"
  6.    ClientHeight    =   2235
  7.    ClientLeft      =   2430
  8.    ClientTop       =   3375
  9.    ClientWidth     =   3390
  10.    ClipControls    =   0   'False
  11.    ControlBox      =   0   'False
  12.    Height          =   2640
  13.    Left            =   2370
  14.    LinkTopic       =   "Form1"
  15.    ScaleHeight     =   149
  16.    ScaleMode       =   3  'Pixel
  17.    ScaleWidth      =   226
  18.    Top             =   3030
  19.    Width           =   3510
  20.    Begin Image Image1 
  21.       Height          =   255
  22.       Left            =   90
  23.       Picture         =   CALENDAR.FRX:0000
  24.       Top             =   60
  25.       Width           =   3225
  26.    End
  27.    Begin Label lblDay 
  28.       Alignment       =   2  'Center
  29.       BackStyle       =   0  'Transparent
  30.       Caption         =   "1"
  31.       ForeColor       =   &H00000000&
  32.       Height          =   240
  33.       Index           =   36
  34.       Left            =   570
  35.       TabIndex        =   37
  36.       Top             =   1920
  37.       Width           =   465
  38.    End
  39.    Begin Label lblDay 
  40.       Alignment       =   2  'Center
  41.       BackStyle       =   0  'Transparent
  42.       Caption         =   "1"
  43.       ForeColor       =   &H000000FF&
  44.       Height          =   240
  45.       Index           =   35
  46.       Left            =   120
  47.       TabIndex        =   38
  48.       Top             =   1920
  49.       Width           =   465
  50.    End
  51.    Begin Label lblDay 
  52.       Alignment       =   2  'Center
  53.       BackStyle       =   0  'Transparent
  54.       Caption         =   "1"
  55.       ForeColor       =   &H00000000&
  56.       Height          =   240
  57.       Index           =   34
  58.       Left            =   2820
  59.       TabIndex        =   39
  60.       Top             =   1680
  61.       Width           =   465
  62.    End
  63.    Begin Label lblDay 
  64.       Alignment       =   2  'Center
  65.       BackStyle       =   0  'Transparent
  66.       Caption         =   "1"
  67.       ForeColor       =   &H00000000&
  68.       Height          =   240
  69.       Index           =   33
  70.       Left            =   2370
  71.       TabIndex        =   40
  72.       Top             =   1680
  73.       Width           =   465
  74.    End
  75.    Begin Label lblDay 
  76.       Alignment       =   2  'Center
  77.       BackStyle       =   0  'Transparent
  78.       Caption         =   "1"
  79.       ForeColor       =   &H00000000&
  80.       Height          =   240
  81.       Index           =   32
  82.       Left            =   1920
  83.       TabIndex        =   41
  84.       Top             =   1680
  85.       Width           =   465
  86.    End
  87.    Begin Label lblDay 
  88.       Alignment       =   2  'Center
  89.       BackStyle       =   0  'Transparent
  90.       Caption         =   "1"
  91.       ForeColor       =   &H00000000&
  92.       Height          =   240
  93.       Index           =   31
  94.       Left            =   1470
  95.       TabIndex        =   43
  96.       Top             =   1680
  97.       Width           =   465
  98.    End
  99.    Begin Label lblDay 
  100.       Alignment       =   2  'Center
  101.       BackStyle       =   0  'Transparent
  102.       Caption         =   "1"
  103.       ForeColor       =   &H00000000&
  104.       Height          =   240
  105.       Index           =   30
  106.       Left            =   1020
  107.       TabIndex        =   42
  108.       Top             =   1680
  109.       Width           =   465
  110.    End
  111.    Begin Label lblDay 
  112.       Alignment       =   2  'Center
  113.       BackStyle       =   0  'Transparent
  114.       Caption         =   "1"
  115.       ForeColor       =   &H00000000&
  116.       Height          =   240
  117.       Index           =   29
  118.       Left            =   570
  119.       TabIndex        =   36
  120.       Top             =   1680
  121.       Width           =   465
  122.    End
  123.    Begin Label lblDay 
  124.       Alignment       =   2  'Center
  125.       BackStyle       =   0  'Transparent
  126.       Caption         =   "1"
  127.       ForeColor       =   &H000000FF&
  128.       Height          =   240
  129.       Index           =   28
  130.       Left            =   120
  131.       TabIndex        =   35
  132.       Top             =   1680
  133.       Width           =   465
  134.    End
  135.    Begin Label lblDay 
  136.       Alignment       =   2  'Center
  137.       BackStyle       =   0  'Transparent
  138.       Caption         =   "1"
  139.       ForeColor       =   &H00000000&
  140.       Height          =   240
  141.       Index           =   27
  142.       Left            =   2820
  143.       TabIndex        =   34
  144.       Top             =   1440
  145.       Width           =   465
  146.    End
  147.    Begin Label lblDay 
  148.       Alignment       =   2  'Center
  149.       BackStyle       =   0  'Transparent
  150.       Caption         =   "1"
  151.       ForeColor       =   &H00000000&
  152.       Height          =   240
  153.       Index           =   26
  154.       Left            =   2370
  155.       TabIndex        =   33
  156.       Top             =   1440
  157.       Width           =   465
  158.    End
  159.    Begin Label lblDay 
  160.       Alignment       =   2  'Center
  161.       BackStyle       =   0  'Transparent
  162.       Caption         =   "1"
  163.       ForeColor       =   &H00000000&
  164.       Height          =   240
  165.       Index           =   25
  166.       Left            =   1920
  167.       TabIndex        =   32
  168.       Top             =   1440
  169.       Width           =   465
  170.    End
  171.    Begin Label lblDay 
  172.       Alignment       =   2  'Center
  173.       BackStyle       =   0  'Transparent
  174.       Caption         =   "1"
  175.       ForeColor       =   &H00000000&
  176.       Height          =   240
  177.       Index           =   24
  178.       Left            =   1470
  179.       TabIndex        =   31
  180.       Top             =   1440
  181.       Width           =   465
  182.    End
  183.    Begin Label lblDay 
  184.       Alignment       =   2  'Center
  185.       BackStyle       =   0  'Transparent
  186.       Caption         =   "1"
  187.       ForeColor       =   &H00000000&
  188.       Height          =   240
  189.       Index           =   23
  190.       Left            =   1020
  191.       TabIndex        =   30
  192.       Top             =   1440
  193.       Width           =   465
  194.    End
  195.    Begin Label lblDay 
  196.       Alignment       =   2  'Center
  197.       BackStyle       =   0  'Transparent
  198.       Caption         =   "1"
  199.       ForeColor       =   &H00000000&
  200.       Height          =   240
  201.       Index           =   22
  202.       Left            =   570
  203.       TabIndex        =   29
  204.       Top             =   1440
  205.       Width           =   465
  206.    End
  207.    Begin Label lblDay 
  208.       Alignment       =   2  'Center
  209.       BackStyle       =   0  'Transparent
  210.       Caption         =   "1"
  211.       ForeColor       =   &H000000FF&
  212.       Height          =   240
  213.       Index           =   21
  214.       Left            =   120
  215.       TabIndex        =   28
  216.       Top             =   1440
  217.       Width           =   465
  218.    End
  219.    Begin Label lblDay 
  220.       Alignment       =   2  'Center
  221.       BackStyle       =   0  'Transparent
  222.       Caption         =   "1"
  223.       ForeColor       =   &H00000000&
  224.       Height          =   240
  225.       Index           =   20
  226.       Left            =   2820
  227.       TabIndex        =   27
  228.       Top             =   1200
  229.       Width           =   465
  230.    End
  231.    Begin Label lblDay 
  232.       Alignment       =   2  'Center
  233.       BackStyle       =   0  'Transparent
  234.       Caption         =   "1"
  235.       ForeColor       =   &H00000000&
  236.       Height          =   240
  237.       Index           =   19
  238.       Left            =   2370
  239.       TabIndex        =   26
  240.       Top             =   1200
  241.       Width           =   465
  242.    End
  243.    Begin Label lblDay 
  244.       Alignment       =   2  'Center
  245.       BackStyle       =   0  'Transparent
  246.       Caption         =   "1"
  247.       ForeColor       =   &H00000000&
  248.       Height          =   240
  249.       Index           =   18
  250.       Left            =   1920
  251.       TabIndex        =   25
  252.       Top             =   1200
  253.       Width           =   465
  254.    End
  255.    Begin Label lblDay 
  256.       Alignment       =   2  'Center
  257.       BackStyle       =   0  'Transparent
  258.       Caption         =   "1"
  259.       ForeColor       =   &H00000000&
  260.       Height          =   240
  261.       Index           =   17
  262.       Left            =   1470
  263.       TabIndex        =   24
  264.       Top             =   1200
  265.       Width           =   465
  266.    End
  267.    Begin Label lblDay 
  268.       Alignment       =   2  'Center
  269.       BackStyle       =   0  'Transparent
  270.       Caption         =   "1"
  271.       ForeColor       =   &H00000000&
  272.       Height          =   240
  273.       Index           =   16
  274.       Left            =   1020
  275.       TabIndex        =   23
  276.       Top             =   1200
  277.       Width           =   465
  278.    End
  279.    Begin Label lblDay 
  280.       Alignment       =   2  'Center
  281.       BackStyle       =   0  'Transparent
  282.       Caption         =   "1"
  283.       ForeColor       =   &H00000000&
  284.       Height          =   240
  285.       Index           =   15
  286.       Left            =   570
  287.       TabIndex        =   22
  288.       Top             =   1200
  289.       Width           =   465
  290.    End
  291.    Begin Label lblDay 
  292.       Alignment       =   2  'Center
  293.       BackStyle       =   0  'Transparent
  294.       Caption         =   "1"
  295.       ForeColor       =   &H000000FF&
  296.       Height          =   240
  297.       Index           =   14
  298.       Left            =   120
  299.       TabIndex        =   21
  300.       Top             =   1200
  301.       Width           =   465
  302.    End
  303.    Begin Label lblDay 
  304.       Alignment       =   2  'Center
  305.       BackStyle       =   0  'Transparent
  306.       Caption         =   "1"
  307.       ForeColor       =   &H00000000&
  308.       Height          =   240
  309.       Index           =   13
  310.       Left            =   2820
  311.       TabIndex        =   20
  312.       Top             =   960
  313.       Width           =   465
  314.    End
  315.    Begin Label lblDay 
  316.       Alignment       =   2  'Center
  317.       BackStyle       =   0  'Transparent
  318.       Caption         =   "1"
  319.       ForeColor       =   &H00000000&
  320.       Height          =   240
  321.       Index           =   12
  322.       Left            =   2370
  323.       TabIndex        =   19
  324.       Top             =   960
  325.       Width           =   465
  326.    End
  327.    Begin Label lblDay 
  328.       Alignment       =   2  'Center
  329.       BackStyle       =   0  'Transparent
  330.       Caption         =   "1"
  331.       ForeColor       =   &H00000000&
  332.       Height          =   240
  333.       Index           =   11
  334.       Left            =   1920
  335.       TabIndex        =   18
  336.       Top             =   960
  337.       Width           =   465
  338.    End
  339.    Begin Label lblDay 
  340.       Alignment       =   2  'Center
  341.       BackStyle       =   0  'Transparent
  342.       Caption         =   "1"
  343.       ForeColor       =   &H00000000&
  344.       Height          =   240
  345.       Index           =   10
  346.       Left            =   1470
  347.       TabIndex        =   17
  348.       Top             =   960
  349.       Width           =   465
  350.    End
  351.    Begin Label lblDay 
  352.       Alignment       =   2  'Center
  353.       BackStyle       =   0  'Transparent
  354.       Caption         =   "1"
  355.       ForeColor       =   &H00000000&
  356.       Height          =   240
  357.       Index           =   9
  358.       Left            =   1020
  359.       TabIndex        =   16
  360.       Top             =   960
  361.       Width           =   465
  362.    End
  363.    Begin Label lblDay 
  364.       Alignment       =   2  'Center
  365.       BackStyle       =   0  'Transparent
  366.       Caption         =   "1"
  367.       ForeColor       =   &H00000000&
  368.       Height          =   240
  369.       Index           =   8
  370.       Left            =   570
  371.       TabIndex        =   15
  372.       Top             =   960
  373.       Width           =   465
  374.    End
  375.    Begin Label lblDay 
  376.       Alignment       =   2  'Center
  377.       BackStyle       =   0  'Transparent
  378.       Caption         =   "1"
  379.       ForeColor       =   &H000000FF&
  380.       Height          =   240
  381.       Index           =   7
  382.       Left            =   120
  383.       TabIndex        =   14
  384.       Top             =   960
  385.       Width           =   465
  386.    End
  387.    Begin Label lblDay 
  388.       Alignment       =   2  'Center
  389.       BackStyle       =   0  'Transparent
  390.       Caption         =   "1"
  391.       ForeColor       =   &H00000000&
  392.       Height          =   240
  393.       Index           =   6
  394.       Left            =   2820
  395.       TabIndex        =   13
  396.       Top             =   720
  397.       Width           =   465
  398.    End
  399.    Begin Label lblDay 
  400.       Alignment       =   2  'Center
  401.       BackStyle       =   0  'Transparent
  402.       Caption         =   "1"
  403.       ForeColor       =   &H00000000&
  404.       Height          =   240
  405.       Index           =   5
  406.       Left            =   2370
  407.       TabIndex        =   12
  408.       Top             =   720
  409.       Width           =   465
  410.    End
  411.    Begin Label lblDay 
  412.       Alignment       =   2  'Center
  413.       BackStyle       =   0  'Transparent
  414.       Caption         =   "1"
  415.       ForeColor       =   &H00000000&
  416.       Height          =   240
  417.       Index           =   4
  418.       Left            =   1920
  419.       TabIndex        =   11
  420.       Top             =   720
  421.       Width           =   465
  422.    End
  423.    Begin Label lblDay 
  424.       Alignment       =   2  'Center
  425.       BackStyle       =   0  'Transparent
  426.       Caption         =   "1"
  427.       ForeColor       =   &H00000000&
  428.       Height          =   240
  429.       Index           =   3
  430.       Left            =   1470
  431.       TabIndex        =   10
  432.       Top             =   720
  433.       Width           =   465
  434.    End
  435.    Begin Label lblDay 
  436.       Alignment       =   2  'Center
  437.       BackStyle       =   0  'Transparent
  438.       Caption         =   "1"
  439.       ForeColor       =   &H00000000&
  440.       Height          =   240
  441.       Index           =   2
  442.       Left            =   1020
  443.       TabIndex        =   9
  444.       Top             =   720
  445.       Width           =   465
  446.    End
  447.    Begin Label lblDay 
  448.       Alignment       =   2  'Center
  449.       BackStyle       =   0  'Transparent
  450.       Caption         =   "1"
  451.       ForeColor       =   &H00000000&
  452.       Height          =   240
  453.       Index           =   1
  454.       Left            =   570
  455.       TabIndex        =   8
  456.       Top             =   720
  457.       Width           =   465
  458.    End
  459.    Begin Label lblDay 
  460.       Alignment       =   2  'Center
  461.       BackStyle       =   0  'Transparent
  462.       Caption         =   "1"
  463.       ForeColor       =   &H000000FF&
  464.       Height          =   240
  465.       Index           =   0
  466.       Left            =   120
  467.       TabIndex        =   7
  468.       Top             =   720
  469.       Width           =   465
  470.    End
  471.    Begin Label lbl 
  472.       Alignment       =   2  'Center
  473.       BackColor       =   &H00000000&
  474.       BackStyle       =   0  'Transparent
  475.       Caption         =   "Sat"
  476.       ForeColor       =   &H00000000&
  477.       Height          =   225
  478.       Index           =   6
  479.       Left            =   2820
  480.       TabIndex        =   0
  481.       Top             =   390
  482.       Width           =   480
  483.    End
  484.    Begin Label lbl 
  485.       Alignment       =   2  'Center
  486.       BackColor       =   &H00000000&
  487.       BackStyle       =   0  'Transparent
  488.       Caption         =   "Fri"
  489.       ForeColor       =   &H00000000&
  490.       Height          =   225
  491.       Index           =   5
  492.       Left            =   2370
  493.       TabIndex        =   3
  494.       Top             =   390
  495.       Width           =   480
  496.    End
  497.    Begin Label lbl 
  498.       Alignment       =   2  'Center
  499.       BackColor       =   &H00000000&
  500.       BackStyle       =   0  'Transparent
  501.       Caption         =   "Thu"
  502.       ForeColor       =   &H00000000&
  503.       Height          =   225
  504.       Index           =   4
  505.       Left            =   1950
  506.       TabIndex        =   6
  507.       Top             =   390
  508.       Width           =   480
  509.    End
  510.    Begin Label lbl 
  511.       Alignment       =   2  'Center
  512.       BackColor       =   &H00000000&
  513.       BackStyle       =   0  'Transparent
  514.       Caption         =   "Wed"
  515.       ForeColor       =   &H00000000&
  516.       Height          =   225
  517.       Index           =   3
  518.       Left            =   1500
  519.       TabIndex        =   5
  520.       Top             =   390
  521.       Width           =   480
  522.    End
  523.    Begin Label lbl 
  524.       Alignment       =   2  'Center
  525.       BackColor       =   &H00000000&
  526.       BackStyle       =   0  'Transparent
  527.       Caption         =   "Tue"
  528.       ForeColor       =   &H00000000&
  529.       Height          =   225
  530.       Index           =   2
  531.       Left            =   1050
  532.       TabIndex        =   4
  533.       Top             =   390
  534.       Width           =   480
  535.    End
  536.    Begin Label lbl 
  537.       Alignment       =   2  'Center
  538.       BackColor       =   &H00000000&
  539.       BackStyle       =   0  'Transparent
  540.       Caption         =   "Mon"
  541.       ForeColor       =   &H00000000&
  542.       Height          =   225
  543.       Index           =   1
  544.       Left            =   600
  545.       TabIndex        =   2
  546.       Top             =   390
  547.       Width           =   480
  548.    End
  549.    Begin Label lbl 
  550.       Alignment       =   2  'Center
  551.       BackStyle       =   0  'Transparent
  552.       Caption         =   "Sun"
  553.       ForeColor       =   &H000000FF&
  554.       Height          =   225
  555.       Index           =   0
  556.       Left            =   120
  557.       TabIndex        =   1
  558.       Top             =   390
  559.       Width           =   480
  560.    End
  561.    Begin Line Line1 
  562.       BorderColor     =   &H00808080&
  563.       Index           =   0
  564.       X1              =   0
  565.       X2              =   232
  566.       Y1              =   43
  567.       Y2              =   43
  568.    End
  569.    Begin Line Line1 
  570.       BorderColor     =   &H00FFFFFF&
  571.       Index           =   1
  572.       X1              =   -2
  573.       X2              =   232
  574.       Y1              =   44
  575.       Y2              =   44
  576.    End
  577. DefInt A-Z
  578. Option Explicit
  579. Dim curIndex As Integer
  580. Dim prevMonat As Integer
  581. Dim prevJahr As Integer
  582. Sub Form_KeyDown (keycode As Integer, Shift As Integer)
  583.     Select Case keycode
  584.     Case &H23 'KEY_END
  585.         
  586.         'determine number of days in month
  587.         Dim monat As Integer
  588.         Dim jahr As Integer
  589.         Dim maxDays As Integer
  590.         monat = Month(DateInfo.thisDate)
  591.         jahr = Year(DateInfo.thisDate)
  592.         Select Case monat
  593.         Case 1, 3, 5, 7, 8, 10, 12
  594.             maxDays = 31
  595.         Case 4, 6, 9, 11
  596.             maxDays = 30
  597.         Case 2
  598.             If jahr Mod 4 = 0 Then
  599.                 maxDays = 29
  600.             Else
  601.                 maxDays = 28
  602.             End If
  603.         End Select
  604.         DateInfo.thisDate = monat & "/" & maxDays & "/" & jahr
  605.         loadCalendar
  606.         
  607.     Case &H24 'KEY_HOME - first of month
  608.         DateInfo.thisDate = Month(DateInfo.thisDate) & "/1/" & Year(DateInfo.thisDate)
  609.         loadCalendar
  610.     Case &H25:  gotoDate 5  'KEY_LEFT  - yesterday
  611.     Case &H26:  gotoDate 7  'KEY_UP    - previous week
  612.     Case &H27:  gotoDate 6  'KEY_RIGHT - tomorrow
  613.     Case &H28:  gotoDate 8  'KEY_DOWN  - next week
  614.     Case &H21:  gotoDate 1  'KEY_PRIOR - previous month
  615.     Case &H22:  gotoDate 3  'KEY_NEXT  - next month
  616.     Case &HD:   'KEY_RETURN
  617.         DateInfo.Action = True
  618.         Unload Me
  619.     Case &H1B 'KEY_ESCAPE
  620.         DateInfo.Action = False
  621.         Unload Me
  622.     End Select
  623. End Sub
  624. Sub Form_Load ()
  625.     loadCalendar
  626. End Sub
  627. Sub gotoDate (whichOne As Integer)
  628.     Select Case whichOne
  629.     Case 0      'back one year
  630.         DateInfo.thisDate = DateAdd("yyyy", -1, DateInfo.thisDate)
  631.         loadCalendar
  632.     Case 1      'back one month
  633.         DateInfo.thisDate = DateAdd("m", -1, DateInfo.thisDate)
  634.         loadCalendar
  635.     Case 2      'today
  636.         DateInfo.thisDate = Format(Now, "m/d/yyyy")
  637.         loadCalendar
  638.     Case 3      'forward one month
  639.         DateInfo.thisDate = DateAdd("m", 1, DateInfo.thisDate)
  640.         loadCalendar
  641.     Case 4      'forward one year
  642.         DateInfo.thisDate = DateAdd("yyyy", 1, DateInfo.thisDate)
  643.         loadCalendar
  644.     Case 5      'yesterday
  645.         DateInfo.thisDate = DateAdd("y", -1, DateInfo.thisDate)
  646.         loadCalendar
  647.     Case 6      'tomorrow
  648.         DateInfo.thisDate = DateAdd("y", 1, DateInfo.thisDate)
  649.         loadCalendar
  650.     Case 7      'previous week
  651.         DateInfo.thisDate = DateAdd("ww", -1, DateInfo.thisDate)
  652.         loadCalendar
  653.     Case 8      'next week
  654.         DateInfo.thisDate = DateAdd("ww", 1, DateInfo.thisDate)
  655.         loadCalendar
  656.     End Select
  657. End Sub
  658. Sub Image1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  659.     image1.Refresh
  660. End Sub
  661. Sub Image1_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  662.     If Button <> 1 Then Exit Sub
  663.     Dim lpRect As RECT
  664.     Dim tp!, lf!, mouseX!
  665.     mouseX! = X / screen.TwipsPerPixelX
  666.     tp! = image1.top
  667.     lf! = image1.left
  668.     Select Case mouseX!
  669.     Case Is < 21
  670.         lpRect.top = 0 + tp!
  671.         lpRect.left = 0 + lf!
  672.         lpRect.right = 21 + lf!
  673.         lpRect.bottom = 16 + tp!
  674.         InvertRect Me.hDC, lpRect
  675.         gotoDate 0
  676.         
  677.     Case 21 To 42
  678.         lpRect.top = 0 + tp!
  679.         lpRect.left = 21 + lf!
  680.         lpRect.right = 42 + lf!
  681.         lpRect.bottom = 16 + tp!
  682.         InvertRect Me.hDC, lpRect
  683.         gotoDate 1
  684.     Case 85 To 130
  685.         lpRect.top = 0 + tp!
  686.         lpRect.left = 85 + lf!
  687.         lpRect.right = 130 + lf!
  688.         lpRect.bottom = 16 + tp!
  689.         InvertRect Me.hDC, lpRect
  690.         gotoDate 2
  691.     Case 173 To 194
  692.         lpRect.top = 0 + tp!
  693.         lpRect.left = 173 + lf!
  694.         lpRect.right = 194 + lf!
  695.         lpRect.bottom = 16 + tp!
  696.         InvertRect Me.hDC, lpRect
  697.         gotoDate 3
  698.     Case Is >= 195
  699.         lpRect.top = 0 + tp!
  700.         lpRect.left = 195 + lf!
  701.         lpRect.right = 214 + lf!
  702.         lpRect.bottom = 16 + tp!
  703.         InvertRect Me.hDC, lpRect
  704.         gotoDate 4
  705.     End Select
  706.     DoEvents
  707.     image1.Refresh
  708. End Sub
  709. Sub lblDay_click (index As Integer)
  710.     'check which panel clicked
  711.     If lblDay(index).Caption = "" Then Exit Sub
  712.     'turn off colors of old number
  713.     Dim startPos As Integer
  714.     startPos = Val(Format(Str$(Month(DateInfo.thisDate)) & "/1/" & Str$(Year(DateInfo.thisDate)), "w")) - 1
  715.     lblDay(startPos + Day(DateInfo.thisDate) - 1).BorderStyle = 0
  716.     'set to new date
  717.     DateInfo.thisDate = Str(Month(DateInfo.thisDate)) & "/" & lblDay(index).Caption & "/" & Str(Year(DateInfo.thisDate))
  718.     'turn on colors
  719.     lblDay(startPos + Val(lblDay(index).Caption) - 1).BorderStyle = 1
  720.     curIndex = index
  721. End Sub
  722. Sub lblDay_DblClick (index As Integer)
  723.     lblDay_click index
  724.     DateInfo.Action = True
  725.     Unload Me
  726. End Sub
  727. Sub loadCalendar ()
  728.     Dim startPos As Integer
  729.     Dim pos As Integer
  730.     Dim maxDays As Integer
  731.     Dim i As Integer
  732.     Dim monat As Integer
  733.     Dim jahr As Integer
  734.     Dim tag As Integer
  735.     tag = Day(DateInfo.thisDate)
  736.     monat = Month(DateInfo.thisDate)
  737.     jahr = Year(DateInfo.thisDate)
  738.     'get variables
  739.     startPos = Val(Format(Str$(monat) & "/1/" & Str$(jahr), "w")) - 1
  740.     pos = startPos
  741.     'determine number of days in month
  742.     Select Case monat
  743.     Case 1, 3, 5, 7, 8, 10, 12
  744.         maxDays = 31
  745.     Case 4, 6, 9, 11
  746.         maxDays = 30
  747.     Case 2
  748.         If jahr Mod 4 = 0 Then
  749.             maxDays = 29
  750.         Else
  751.             maxDays = 28
  752.         End If
  753.     End Select
  754.     If tag > maxDays Then tag = maxDays
  755.     DateInfo.thisDate = DateValue(monat & "/" & tag & "/" & jahr)
  756.     'load the calendar
  757.     If monat <> prevMonat Or jahr <> prevJahr Or IsNull(prevMonat) Or IsNull(prevJahr) Then
  758.         For i = 0 To 36
  759.             lblDay(i).Caption = ""
  760.             lblDay(i).BorderStyle = 0
  761.         Next
  762.         For i = 1 To maxDays
  763.             lblDay(pos).Caption = i
  764.             pos = pos + 1
  765.         Next i
  766.         Me.Caption = Format$(DateInfo.thisDate, "mmmm, yyyy")
  767.     Else
  768.         For i = 0 To 36
  769.             If lblDay(i).BorderStyle Then lblDay(i).BorderStyle = 0
  770.         Next
  771.     End If
  772.     'set calendar
  773.     lblDay(startPos + tag - 1).BorderStyle = 1
  774.     curIndex = startPos + tag - 1
  775.     prevMonat = monat
  776.     prevJahr = jahr
  777. End Sub
  778.