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

  1. VERSION 2.00
  2. Begin Form Main_Form 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "WindChill Calculator"
  5.    ClientHeight    =   3870
  6.    ClientLeft      =   1290
  7.    ClientTop       =   2205
  8.    ClientWidth     =   7425
  9.    Height          =   4560
  10.    Icon            =   MAIN_FOR.FRX:0000
  11.    Left            =   1230
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   3870
  16.    ScaleWidth      =   7425
  17.    Top             =   1575
  18.    Width           =   7545
  19.    Begin CommandButton Command2 
  20.       BackColor       =   &H00C0C0C0&
  21.       Caption         =   "Another"
  22.       Height          =   495
  23.       Left            =   3960
  24.       TabIndex        =   12
  25.       Top             =   3000
  26.       Width           =   3255
  27.    End
  28.    Begin CommandButton Command1 
  29.       BackColor       =   &H00C0C0C0&
  30.       Caption         =   "Convert"
  31.       Default         =   -1  'True
  32.       Height          =   495
  33.       Left            =   3960
  34.       TabIndex        =   11
  35.       Top             =   2520
  36.       Width           =   3255
  37.    End
  38.    Begin PictureBox Picture3 
  39.       BackColor       =   &H00C0C0C0&
  40.       BorderStyle     =   0  'None
  41.       Height          =   975
  42.       Left            =   240
  43.       ScaleHeight     =   975
  44.       ScaleWidth      =   3375
  45.       TabIndex        =   16
  46.       Top             =   2520
  47.       Width           =   3375
  48.       Begin Label Label9 
  49.          Alignment       =   2  'Center
  50.          BackColor       =   &H00C0C0C0&
  51.          ForeColor       =   &H00FF0000&
  52.          Height          =   255
  53.          Left            =   1800
  54.          TabIndex        =   0
  55.          Top             =   360
  56.          Width           =   1455
  57.       End
  58.       Begin Label Label10 
  59.          Alignment       =   2  'Center
  60.          BackColor       =   &H00C0C0C0&
  61.          Caption         =   "WindChill  is =>"
  62.          Height          =   255
  63.          Left            =   120
  64.          TabIndex        =   1
  65.          Top             =   360
  66.          Width           =   1575
  67.       End
  68.    End
  69.    Begin PictureBox Picture2 
  70.       BackColor       =   &H00C0C0C0&
  71.       BorderStyle     =   0  'None
  72.       Height          =   1815
  73.       Left            =   3960
  74.       ScaleHeight     =   1815
  75.       ScaleWidth      =   3255
  76.       TabIndex        =   13
  77.       Top             =   360
  78.       Width           =   3255
  79.       Begin Label Label8 
  80.          Alignment       =   2  'Center
  81.          BackColor       =   &H00C0C0C0&
  82.          Caption         =   "Degrees Celcius"
  83.          Height          =   255
  84.          Left            =   1320
  85.          TabIndex        =   2
  86.          Top             =   1200
  87.          Width           =   1815
  88.       End
  89.       Begin Label Label6 
  90.          Alignment       =   2  'Center
  91.          BackColor       =   &H00C0C0C0&
  92.          ForeColor       =   &H00FF0000&
  93.          Height          =   255
  94.          Left            =   120
  95.          TabIndex        =   4
  96.          Top             =   1200
  97.          Width           =   1095
  98.       End
  99.       Begin Label Label7 
  100.          Alignment       =   2  'Center
  101.          BackColor       =   &H00C0C0C0&
  102.          Caption         =   "Meters/Second"
  103.          Height          =   255
  104.          Left            =   1320
  105.          TabIndex        =   3
  106.          Top             =   600
  107.          Width           =   1815
  108.       End
  109.       Begin Label Label5 
  110.          Alignment       =   2  'Center
  111.          BackColor       =   &H00C0C0C0&
  112.          ForeColor       =   &H00FF0000&
  113.          Height          =   255
  114.          Left            =   120
  115.          TabIndex        =   5
  116.          Top             =   600
  117.          Width           =   1095
  118.       End
  119.       Begin Label Label4 
  120.          BackColor       =   &H00C0C0C0&
  121.          Caption         =   "Conversion"
  122.          Height          =   255
  123.          Left            =   240
  124.          TabIndex        =   15
  125.          Top             =   120
  126.          Width           =   1575
  127.       End
  128.    End
  129.    Begin PictureBox Picture1 
  130.       BackColor       =   &H00C0C0C0&
  131.       BorderStyle     =   0  'None
  132.       Height          =   1815
  133.       Left            =   240
  134.       ScaleHeight     =   1815
  135.       ScaleWidth      =   3375
  136.       TabIndex        =   8
  137.       Top             =   360
  138.       Width           =   3375
  139.       Begin TextBox Text2 
  140.          BackColor       =   &H00C0C0C0&
  141.          BorderStyle     =   0  'None
  142.          ForeColor       =   &H00FF0000&
  143.          Height          =   255
  144.          Left            =   120
  145.          TabIndex        =   10
  146.          Top             =   1200
  147.          Width           =   855
  148.       End
  149.       Begin TextBox Text1 
  150.          BackColor       =   &H00C0C0C0&
  151.          BorderStyle     =   0  'None
  152.          ForeColor       =   &H00FF0000&
  153.          Height          =   255
  154.          Left            =   120
  155.          TabIndex        =   9
  156.          Top             =   600
  157.          Width           =   855
  158.       End
  159.       Begin Label Label2 
  160.          Alignment       =   2  'Center
  161.          BackColor       =   &H00C0C0C0&
  162.          Caption         =   "Temperature Degrees F."
  163.          Height          =   255
  164.          Left            =   1080
  165.          TabIndex        =   6
  166.          Top             =   1200
  167.          Width           =   2175
  168.       End
  169.       Begin Label Label1 
  170.          Alignment       =   2  'Center
  171.          BackColor       =   &H00C0C0C0&
  172.          Caption         =   " Wind Speed MPH"
  173.          Height          =   255
  174.          Left            =   1080
  175.          TabIndex        =   7
  176.          Top             =   600
  177.          Width           =   2175
  178.       End
  179.       Begin Label Label3 
  180.          BackColor       =   &H00C0C0C0&
  181.          Caption         =   "Enter Here"
  182.          Height          =   255
  183.          Left            =   120
  184.          TabIndex        =   14
  185.          Top             =   120
  186.          Width           =   1695
  187.       End
  188.    End
  189.    Begin Menu FileCmd 
  190.       Caption         =   "&File"
  191.       Begin Menu AboutCmd 
  192.          Caption         =   "About"
  193.          Shortcut        =   ^A
  194.       End
  195.       Begin Menu spacer 
  196.          Caption         =   "-"
  197.       End
  198.       Begin Menu ExitCmd 
  199.          Caption         =   "Exit"
  200.          Shortcut        =   ^E
  201.       End
  202.    End
  203.    Begin Menu HelpCmd 
  204.       Caption         =   "&Help"
  205.    End
  206. Sub AboutCmd_Click ()
  207.     about.Show
  208. End Sub
  209. Sub BorderBox (source1 As Control, source2 As Control)
  210.     bleft% = source1.Left - 45
  211.     btop% = source1.Top - 20
  212.     bwide% = source1.Width + 40
  213.     bhigh% = source1.Height + 15
  214.     source2.Line (bleft%, btop%)-Step(bwide%, 0), 0
  215.     source2.Line -Step(0, bhigh%), &HFFFFFF
  216.     source2.Line -Step(-bwide%, 0), &HFFFFFF
  217.     source2.Line -Step(0, -bhigh%), 0
  218. End Sub
  219. Sub BorderBoxRaised (source1 As Control, source2 As Form)
  220.     bleft% = source1.Left - 20
  221.     btop% = source1.Top - 20
  222.     bwide% = source1.Width + 15
  223.     bhigh% = source1.Height + 15
  224.     source2.Line (bleft%, btop%)-Step(bwide%, 0), &HFFFFFF
  225.     source2.Line -Step(0, bhigh%), 0
  226.     source2.Line -Step(-bwide%, 0), 0
  227.     source2.Line -Step(0, -bhigh%), &HFFFFFF
  228. End Sub
  229. Sub Command1_Click ()
  230.     Dim s#, t#, ms#, c#, wc#, a, b
  231.     msg$ = "You must enter both MPH and 
  232.     title$ = "Entry Error"
  233.     s# = Val(text1.text)
  234.     t# = Val(text2.text)
  235.     If s# = 0 Or t# = 0 Then  'forgot to enter both numbers
  236.     MsgBox msg$, 64, title$
  237.     If s# = 0 Then text1.SetFocus
  238.     If t# = 0 Then text2.SetFocus
  239.     Exit Sub
  240.     End If
  241.     ms# = s# * .444         'convert to meters/second
  242.     c# = ((t# - 32) * 5 / 9)'convert to degrees Celcius
  243.     'MAIN WIND CHILL FORMULA
  244.     wc# = 1.8 * (33 - (((Sqr(100 * ms#) + 10.45 - ms#) * (33 - (t# - 32) * .55))) / 22.066) + 32
  245.     label5.caption = Format$(ms#, "##,###.00")
  246.     label6.caption = Format$(c#, "##,###.00")
  247.     label9.caption = Format$(wc#, "##,###.0") + "  
  248. End Sub
  249. Sub Command2_Click ()
  250.     text1.text = ""
  251.     text2.text = ""
  252.     label5.caption = ""
  253.     label6.caption = ""
  254.     label9.caption = ""
  255.     text1.SetFocus
  256. End Sub
  257. Sub ExitCmd_Click ()
  258.     End
  259. End Sub
  260. Sub Form_Load ()
  261.     Width = Screen.Width * .8  ' Set height of form.
  262.     Height = Screen.Height * .65    ' Set width of form.
  263.     Left = (Screen.Width - Width) / 2   ' Center form horizontally.
  264.     Top = (Screen.Height - Height) / 2  ' Center form vertically.
  265. End Sub
  266. Sub Form_Paint ()
  267.     'SYNTAX FOR BORDERBOXRAISED
  268.     'PICTURE, FORM NAME
  269.     BorderBoxRaised picture1, main_form
  270.     BorderBoxRaised picture2, main_form
  271.     BorderBoxRaised picture3, main_form
  272.     'SYNTAX FOR BORDERBOX
  273.     'TEXT or LABEL, PICTURE
  274.     BorderBox text1, picture1
  275.     BorderBox text2, picture1
  276.     BorderBox label1, picture1
  277.     BorderBox label2, picture1
  278.     BorderBox label5, picture2
  279.     BorderBox label6, picture2
  280.     BorderBox label7, picture2
  281.     BorderBox label8, picture2
  282.     BorderBox label9, picture3
  283.     BorderBox label10, picture3
  284.     text1.SetFocus
  285. End Sub
  286. Sub HelpCmd_Click ()
  287.     help.Show
  288. End Sub
  289. Sub Text1_Change ()
  290.     msg$ = "Your number is restricted" + Chr$(13) + Chr$(10) + "to a maximum of 4 digits."
  291.     title$ = "Entry Error"
  292.     If Len(text1.text) > 4 Then
  293.     MsgBox msg$, 64, title$
  294.     text1.text = ""
  295.     End If
  296. End Sub
  297. Sub Text1_KeyPress (keyascii As Integer)
  298.     a% = keyascii       'TRAP FOR POSTIVE WHOLE NUMBERS
  299.     Select Case keyascii
  300.     Case 0 To 7
  301.     GoSub EntryError
  302.     Case 9 To 46
  303.     GoSub EntryError
  304.     Case 58 To 255
  305.     GoSub EntryError
  306.     End Select
  307. Exit Sub
  308. EntryError:
  309.     keyascii = 0
  310.     msg$ = "Enter Postive Whole Numbers Only"
  311.     title$ = "Entry Error"
  312.     MsgBox (msg$), 48, title$
  313.     Return
  314. End Sub
  315. Sub Text2_Change ()
  316.     msg$ = "Your number is restricted" + Chr$(13) + Chr$(10) + "to a maximum of 4 digits."
  317.     title$ = "Entry Error"
  318.     If Len(text2.text) > 5 Then
  319.     MsgBox msg$, 64, title$
  320.     text2.text = ""
  321.     End If
  322. End Sub
  323. Sub Text2_KeyPress (keyascii As Integer)
  324.     a% = keyascii       'TRAP FOR WHOLE NUMBERS
  325.     Select Case keyascii
  326.     Case 0 To 7
  327.     GoSub EntryError2
  328.     Case 9 To 44
  329.     GoSub EntryError2
  330.     Case 46
  331.     GoSub EntryError2
  332.     Case 58 To 255
  333.     GoSub EntryError2
  334.     End Select
  335. Exit Sub
  336. EntryError2:
  337.     keyascii = 0
  338.     msg$ = "Enter Whole Numbers Only"
  339.     title$ = "Entry Error"
  340.     MsgBox (msg$), 48, title$
  341.     Return
  342. End Sub
  343.