home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / graphics / highlo.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1993-05-16  |  1.7 KB  |  59 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Daily Highs"
  4.    ClientHeight    =   4260
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1815
  7.    ClientWidth     =   8205
  8.    Height          =   4665
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4260
  12.    ScaleWidth      =   8205
  13.    Top             =   1470
  14.    Width           =   8325
  15. Option Explicit
  16. Const PIXEL = 3
  17. Sub Form_Activate ()
  18.     Const MAX_TEMP = 110
  19.     Const MIN_TEMP = -50
  20.     Static DailyHighs(31) As Integer
  21.     Dim i As Integer, DaysInMonth As Integer
  22.     Dim fhandle As Integer
  23.     Dim fname As String
  24.     i = 1
  25.     fhandle = FreeFile
  26.     fname = "c:\vbdemos\graphics\january.dat"
  27.     Open fname For Input As fhandle
  28.     While Not EOF(fhandle)
  29.         Input #fhandle, DailyHighs(i)
  30.         i = i + 1
  31.     Wend
  32.     Close fhandle
  33.     'Now that the number of days in the month can be determined,
  34.     'set the scale mode of the graph accordingly. The graph thus
  35.     'becomes appropriate for charting the temperature.
  36.     DaysInMonth = i - 1
  37.     form1.ScaleMode = PIXEL
  38.     Scale (0, MAX_TEMP)-(DaysInMonth + 1, MIN_TEMP)
  39.     'Draw a horizontal line representing 0.
  40.     Line (1, 0)-(DaysInMonth + 1, 0)
  41.     'Draw the graph.
  42.     For i = 2 To DaysInMonth
  43.         Line (i - 1, DailyHighs(i - 1))-(i, DailyHighs(i))
  44.     Next i
  45.     'Print the vertical scale
  46.     For i = MAX_TEMP To MIN_TEMP + 20 Step -10
  47.         currentx = 0
  48.         currenty = i
  49.         Print Trim$(Str$(i))
  50.     Next i
  51.     'Print the horizontal scale
  52.     currenty = MIN_TEMP + 10
  53.     For i = 1 To DaysInMonth
  54.         currentx = i
  55.         Print Trim$(Str$(i));
  56.     Next i
  57.         
  58. End Sub
  59.