home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / calendar / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-09-06  |  16.0 KB  |  581 lines

  1. VERSION 2.00
  2. Begin Form frmcalendar 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Calendar"
  5.    ClientHeight    =   2865
  6.    ClientLeft      =   930
  7.    ClientTop       =   1485
  8.    ClientWidth     =   4290
  9.    ControlBox      =   0   'False
  10.    Height          =   3270
  11.    Icon            =   FORM1.FRX:0000
  12.    Left            =   870
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2865
  17.    ScaleWidth      =   4290
  18.    Top             =   1140
  19.    Width           =   4410
  20.    Begin ComboBox cboyear 
  21.       Height          =   300
  22.       Left            =   2880
  23.       Style           =   2  'Dropdown List
  24.       TabIndex        =   3
  25.       Top             =   360
  26.       Width           =   1215
  27.    End
  28.    Begin ComboBox cbomonth 
  29.       Height          =   300
  30.       Left            =   120
  31.       Style           =   2  'Dropdown List
  32.       TabIndex        =   1
  33.       Top             =   360
  34.       Width           =   2415
  35.    End
  36.    Begin CommandButton cmdcancel 
  37.       Cancel          =   -1  'True
  38.       Caption         =   "&Cancel"
  39.       Height          =   345
  40.       Left            =   3000
  41.       TabIndex        =   5
  42.       Top             =   2400
  43.       Width           =   1215
  44.    End
  45.    Begin CommandButton cmdok 
  46.       Caption         =   "&OK"
  47.       Default         =   -1  'True
  48.       Height          =   345
  49.       Left            =   3000
  50.       TabIndex        =   4
  51.       Top             =   1965
  52.       Width           =   1215
  53.    End
  54.    Begin Label lbldate 
  55.       Alignment       =   2  'Center
  56.       ForeColor       =   &H00000080&
  57.       Height          =   615
  58.       Left            =   2880
  59.       TabIndex        =   38
  60.       Top             =   1200
  61.       Width           =   1215
  62.    End
  63.    Begin Label lblday 
  64.       Alignment       =   2  'Center
  65.       ForeColor       =   &H00000080&
  66.       Height          =   255
  67.       Left            =   2880
  68.       TabIndex        =   37
  69.       Top             =   1000
  70.       Width           =   1215
  71.    End
  72.    Begin Label lblnumber 
  73.       Alignment       =   2  'Center
  74.       Caption         =   "29"
  75.       Height          =   285
  76.       Index           =   28
  77.       Left            =   240
  78.       TabIndex        =   7
  79.       Top             =   2400
  80.       Width           =   300
  81.    End
  82.    Begin Label lblnumber 
  83.       Alignment       =   2  'Center
  84.       Caption         =   "30"
  85.       Height          =   285
  86.       Index           =   29
  87.       Left            =   600
  88.       TabIndex        =   8
  89.       Top             =   2400
  90.       Width           =   300
  91.    End
  92.    Begin Label lblnumber 
  93.       Alignment       =   2  'Center
  94.       Caption         =   "31"
  95.       Height          =   285
  96.       Index           =   30
  97.       Left            =   960
  98.       TabIndex        =   9
  99.       Top             =   2400
  100.       Width           =   300
  101.    End
  102.    Begin Label lblnumber 
  103.       Alignment       =   2  'Center
  104.       Caption         =   "16"
  105.       Height          =   285
  106.       Index           =   15
  107.       Left            =   600
  108.       TabIndex        =   10
  109.       Top             =   1680
  110.       Width           =   300
  111.    End
  112.    Begin Label lblnumber 
  113.       Alignment       =   2  'Center
  114.       Caption         =   "17"
  115.       Height          =   285
  116.       Index           =   16
  117.       Left            =   960
  118.       TabIndex        =   11
  119.       Top             =   1680
  120.       Width           =   300
  121.    End
  122.    Begin Label lblnumber 
  123.       Alignment       =   2  'Center
  124.       Caption         =   "18"
  125.       Height          =   285
  126.       Index           =   17
  127.       Left            =   1320
  128.       TabIndex        =   12
  129.       Top             =   1680
  130.       Width           =   300
  131.    End
  132.    Begin Label lblnumber 
  133.       Alignment       =   2  'Center
  134.       Caption         =   "19"
  135.       Height          =   285
  136.       Index           =   18
  137.       Left            =   1680
  138.       TabIndex        =   13
  139.       Top             =   1680
  140.       Width           =   300
  141.    End
  142.    Begin Label lblnumber 
  143.       Alignment       =   2  'Center
  144.       Caption         =   "20"
  145.       Height          =   285
  146.       Index           =   19
  147.       Left            =   2040
  148.       TabIndex        =   36
  149.       Top             =   1680
  150.       Width           =   300
  151.    End
  152.    Begin Label lblnumber 
  153.       Alignment       =   2  'Center
  154.       Caption         =   "21"
  155.       Height          =   285
  156.       Index           =   20
  157.       Left            =   2400
  158.       TabIndex        =   35
  159.       Top             =   1680
  160.       Width           =   300
  161.    End
  162.    Begin Label lblnumber 
  163.       Alignment       =   2  'Center
  164.       Caption         =   "15"
  165.       Height          =   285
  166.       Index           =   14
  167.       Left            =   240
  168.       TabIndex        =   34
  169.       Top             =   1680
  170.       Width           =   300
  171.    End
  172.    Begin Label lblnumber 
  173.       Alignment       =   2  'Center
  174.       Caption         =   "23"
  175.       Height          =   285
  176.       Index           =   22
  177.       Left            =   600
  178.       TabIndex        =   33
  179.       Top             =   2040
  180.       Width           =   300
  181.    End
  182.    Begin Label lblnumber 
  183.       Alignment       =   2  'Center
  184.       Caption         =   "24"
  185.       Height          =   285
  186.       Index           =   23
  187.       Left            =   960
  188.       TabIndex        =   32
  189.       Top             =   2040
  190.       Width           =   300
  191.    End
  192.    Begin Label lblnumber 
  193.       Alignment       =   2  'Center
  194.       Caption         =   "25"
  195.       Height          =   285
  196.       Index           =   24
  197.       Left            =   1320
  198.       TabIndex        =   31
  199.       Top             =   2040
  200.       Width           =   300
  201.    End
  202.    Begin Label lblnumber 
  203.       Alignment       =   2  'Center
  204.       Caption         =   "26"
  205.       Height          =   285
  206.       Index           =   25
  207.       Left            =   1680
  208.       TabIndex        =   30
  209.       Top             =   2040
  210.       Width           =   300
  211.    End
  212.    Begin Label lblnumber 
  213.       Alignment       =   2  'Center
  214.       Caption         =   "27"
  215.       Height          =   285
  216.       Index           =   26
  217.       Left            =   2040
  218.       TabIndex        =   29
  219.       Top             =   2040
  220.       Width           =   300
  221.    End
  222.    Begin Label lblnumber 
  223.       Alignment       =   2  'Center
  224.       Caption         =   "28"
  225.       Height          =   285
  226.       Index           =   27
  227.       Left            =   2400
  228.       TabIndex        =   28
  229.       Top             =   2040
  230.       Width           =   300
  231.    End
  232.    Begin Label lblnumber 
  233.       Alignment       =   2  'Center
  234.       Caption         =   "22"
  235.       Height          =   285
  236.       Index           =   21
  237.       Left            =   240
  238.       TabIndex        =   27
  239.       Top             =   2040
  240.       Width           =   300
  241.    End
  242.    Begin Label lblnumber 
  243.       Alignment       =   2  'Center
  244.       Caption         =   "9"
  245.       Height          =   285
  246.       Index           =   8
  247.       Left            =   600
  248.       TabIndex        =   26
  249.       Top             =   1320
  250.       Width           =   300
  251.    End
  252.    Begin Label lblnumber 
  253.       Alignment       =   2  'Center
  254.       Caption         =   "10"
  255.       Height          =   285
  256.       Index           =   9
  257.       Left            =   960
  258.       TabIndex        =   25
  259.       Top             =   1320
  260.       Width           =   300
  261.    End
  262.    Begin Label lblnumber 
  263.       Alignment       =   2  'Center
  264.       Caption         =   "11"
  265.       Height          =   285
  266.       Index           =   10
  267.       Left            =   1320
  268.       TabIndex        =   24
  269.       Top             =   1320
  270.       Width           =   300
  271.    End
  272.    Begin Label lblnumber 
  273.       Alignment       =   2  'Center
  274.       Caption         =   "12"
  275.       Height          =   285
  276.       Index           =   11
  277.       Left            =   1680
  278.       TabIndex        =   23
  279.       Top             =   1320
  280.       Width           =   300
  281.    End
  282.    Begin Label lblnumber 
  283.       Alignment       =   2  'Center
  284.       Caption         =   "13"
  285.       Height          =   285
  286.       Index           =   12
  287.       Left            =   2040
  288.       TabIndex        =   22
  289.       Top             =   1320
  290.       Width           =   300
  291.    End
  292.    Begin Label lblnumber 
  293.       Alignment       =   2  'Center
  294.       Caption         =   "14"
  295.       Height          =   285
  296.       Index           =   13
  297.       Left            =   2400
  298.       TabIndex        =   21
  299.       Top             =   1320
  300.       Width           =   300
  301.    End
  302.    Begin Label lblnumber 
  303.       Alignment       =   2  'Center
  304.       Caption         =   "8"
  305.       Height          =   285
  306.       Index           =   7
  307.       Left            =   240
  308.       TabIndex        =   20
  309.       Top             =   1320
  310.       Width           =   300
  311.    End
  312.    Begin Label lblnumber 
  313.       Alignment       =   2  'Center
  314.       Caption         =   "2"
  315.       Height          =   285
  316.       Index           =   1
  317.       Left            =   600
  318.       TabIndex        =   19
  319.       Top             =   960
  320.       Width           =   300
  321.    End
  322.    Begin Label lblnumber 
  323.       Alignment       =   2  'Center
  324.       Caption         =   "3"
  325.       Height          =   285
  326.       Index           =   2
  327.       Left            =   960
  328.       TabIndex        =   18
  329.       Top             =   960
  330.       Width           =   300
  331.    End
  332.    Begin Label lblnumber 
  333.       Alignment       =   2  'Center
  334.       Caption         =   "4"
  335.       Height          =   285
  336.       Index           =   3
  337.       Left            =   1320
  338.       TabIndex        =   17
  339.       Top             =   960
  340.       Width           =   300
  341.    End
  342.    Begin Label lblnumber 
  343.       Alignment       =   2  'Center
  344.       Caption         =   "5"
  345.       Height          =   285
  346.       Index           =   4
  347.       Left            =   1680
  348.       TabIndex        =   16
  349.       Top             =   960
  350.       Width           =   300
  351.    End
  352.    Begin Label lblnumber 
  353.       Alignment       =   2  'Center
  354.       Caption         =   "6"
  355.       Height          =   285
  356.       Index           =   5
  357.       Left            =   2040
  358.       TabIndex        =   15
  359.       Top             =   960
  360.       Width           =   300
  361.    End
  362.    Begin Label lblnumber 
  363.       Alignment       =   2  'Center
  364.       Caption         =   "7"
  365.       Height          =   285
  366.       Index           =   6
  367.       Left            =   2400
  368.       TabIndex        =   14
  369.       Top             =   960
  370.       Width           =   300
  371.    End
  372.    Begin Label lblnumber 
  373.       Alignment       =   2  'Center
  374.       Caption         =   "1"
  375.       Height          =   285
  376.       Index           =   0
  377.       Left            =   240
  378.       TabIndex        =   6
  379.       Top             =   960
  380.       Width           =   300
  381.    End
  382.    Begin Shape Shape1 
  383.       Height          =   1935
  384.       Left            =   120
  385.       Top             =   840
  386.       Width           =   2655
  387.    End
  388.    Begin Label Label1 
  389.       Caption         =   "&Year"
  390.       Height          =   255
  391.       Index           =   1
  392.       Left            =   2880
  393.       TabIndex        =   2
  394.       Top             =   120
  395.       Width           =   495
  396.    End
  397.    Begin Label Label1 
  398.       Caption         =   "&Month"
  399.       Height          =   255
  400.       Index           =   0
  401.       Left            =   120
  402.       TabIndex        =   0
  403.       Top             =   120
  404.       Width           =   615
  405.    End
  406. 'This code has been developed for EVERYONE'S use
  407. ' don't re-distribute this without ALL original files!!
  408. 'Phil Jones 1994
  409. Option Explicit
  410. Dim selectedate%
  411. Sub cbomonth_click ()
  412. Call setday
  413. Call lblnumber_click(selectedate% - 1)
  414. End Sub
  415. Sub cboyear_Click ()
  416. Static once% ' get rid of first click event
  417. If Not once Then
  418.     once = True
  419.     Exit Sub
  420. End If
  421. Call cbomonth_click
  422. End Sub
  423. Sub checkdate (month1%, year1%)
  424. Dim i%, value%, date1$
  425. For i% = 28 To 32
  426.     date1$ = (Str$(month1%) + "/" + Str$(i%) + "/" + Str$(year1%))
  427.         If IsDate(date1$) Then
  428.             value% = i%
  429.         Else
  430.             Call displaynumbers(value%)
  431.             Exit Sub
  432.         End If
  433. Next i%
  434. End Sub
  435. Sub CmdCancel_Click ()
  436. Unload frmcalendar
  437. End Sub
  438. Sub cmdOK_Click ()
  439. Dim month1%, day1%, year1%, date1$
  440. day1% = selectedate%
  441. month1% = cbomonth.ListIndex + 1
  442. year1% = cboyear.ListIndex + 1960
  443. date1$ = (Str$(month1%) + "/" + Str$(day1%) + "/" + Str$(year1%))
  444. date1$ = Format$(date1$, "general date")
  445. MsgBox Format$(date1$, "long date") 'do whatever here to pass the date where
  446.                                     'you need it!
  447. End Sub
  448. Function determinemonth% ()
  449. Dim i%
  450. i% = cbomonth.ListIndex'which month is selected?
  451. determinemonth% = i% + 1
  452. End Function
  453. Function determineyear% ()
  454. Dim i%
  455. i% = cboyear.ListIndex'which year was selected?
  456. If i% = -1 Then Exit Function'problem!!
  457. determineyear% = CInt(Trim(cboyear.List(i%)))
  458. End Function
  459. Sub displaynumbers (number%)
  460. Dim i%
  461. For i% = 28 To 30
  462.     lblnumber(i%).Visible = False
  463. Next i%
  464. For i% = 28 To number% - 1
  465.     lblnumber(i%).Visible = True
  466. Next i%
  467. End Sub
  468. Sub fillcbomonth ()
  469. cbomonth.AddItem "January"
  470. cbomonth.AddItem "February"
  471. cbomonth.AddItem "March"
  472. cbomonth.AddItem "April"
  473. cbomonth.AddItem "May"
  474. cbomonth.AddItem "June"
  475. cbomonth.AddItem "July"
  476. cbomonth.AddItem "August"
  477. cbomonth.AddItem "September"
  478. cbomonth.AddItem "October"
  479. cbomonth.AddItem "November"
  480. cbomonth.AddItem "December"
  481. End Sub
  482. Sub fillcboyear ()
  483. Dim i%
  484. For i% = 1960 To 2060'put whatever years tyou want here,
  485.     cboyear.AddItem Str$(i%)'but don't forget to also change the code in setdate
  486. Next i%
  487. End Sub
  488. Sub Form_Load ()
  489. selectedate% = CInt(Format$(Now, "dd"))
  490. 'fill month combo box
  491. Call fillcbomonth
  492. 'fill year combo box
  493. Call fillcboyear
  494. 'put current date and year im combo box
  495. Call setdate
  496. 'set current name for day
  497. Dim r%, caption1$
  498. r% = Weekday(Format$(Now, "general date"))
  499. If r% = 1 Then
  500.     caption1$ = "Sunday"
  501. ElseIf r% = 2 Then
  502.     caption1 = "Monday"
  503. ElseIf r% = 3 Then
  504.     caption1 = "Tuesday"
  505. ElseIf r% = 4 Then
  506.     caption1 = "Wednesday"
  507. ElseIf r% = 5 Then
  508.     caption1 = "Thursday"
  509. ElseIf r% = 6 Then
  510.     caption1 = "Friday"
  511.     caption1 = "Saturday"
  512. End If
  513. lblday.Caption = caption1$
  514. End Sub
  515. Sub lblnumber_click (Index As Integer)
  516. Dim i%
  517. On Error GoTo err1
  518. For i% = 0 To 30
  519.     lblnumber(i%).BorderStyle = 0
  520. Next i%
  521. If lblnumber(Index).BorderStyle = 1 Then
  522.     lblnumber(Index).BorderStyle = 0
  523.     lblnumber(Index).BorderStyle = 1
  524. End If
  525. selectedate% = Index + 1
  526. Dim month1%, day1%, year1%, date1$
  527. day1% = selectedate%
  528. month1% = cbomonth.ListIndex + 1
  529. year1% = cboyear.ListIndex + 1960
  530. date1$ = (Str$(month1%) + "/" + Str$(day1%) + "/" + Str$(year1%))
  531. 'date1$ = Format$(date1$, "general date")
  532. Dim r%
  533. Dim caption1$
  534. r% = Weekday(date1$)
  535. If r% = 1 Then
  536.     caption1$ = "Sunday"
  537. ElseIf r% = 2 Then
  538.     caption1 = "Monday"
  539. ElseIf r% = 3 Then
  540.     caption1 = "Tuesday"
  541. ElseIf r% = 4 Then
  542.     caption1 = "Wednesday"
  543. ElseIf r% = 5 Then
  544.     caption1 = "Thursday"
  545. ElseIf r% = 6 Then
  546.     caption1 = "Friday"
  547.     caption1 = "Saturday"
  548. End If
  549. lblday.Caption = caption1$
  550. lbldate.Caption = Format$(date1$, "long date")
  551. err1:
  552.     If Err = 0 Then Exit Sub
  553.     If Err = 13 Then
  554.         selectedate% = selectedate% - 1
  555.     Exit Sub
  556.     End If
  557.     End Sub
  558. Sub setdate ()
  559. 'since the list starts at 1960, this is 0, so we're going
  560. ' to get the date, and subtract 1960 from it, and use this
  561. 'as our starting listindex
  562. 'put whatever value you need to for the first year
  563. 'year
  564. Dim r%, i%
  565. r% = CInt(Format$(Now, "yyyy"))
  566. i% = r% - 1960
  567. cboyear.ListIndex = i%
  568. 'month
  569. r% = CInt(Format$(Now, "mm"))
  570. cbomonth.ListIndex = (r% - 1)
  571. r% = CInt(Format$(Now, "dd"))
  572. lblnumber(r% - 1).BorderStyle = 1
  573. selectedate% = r%
  574. End Sub
  575. Sub setday ()
  576. Dim month1%, year1%
  577. month1% = determinemonth()
  578. year1% = determineyear()
  579. Call checkdate(month1%, year1%)
  580. End Sub
  581.