Option Explicit On 
Option Strict On

Public Class frmTemp
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
        Friend WithEvents lblTempF As System.Windows.Forms.Label
    Friend WithEvents hsbTemp As System.Windows.Forms.HScrollBar
    Friend WithEvents lblTempC As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Label3 As System.Windows.Forms.Label
    Friend WithEvents lblRed As System.Windows.Forms.Label
    Friend WithEvents lblBlue As System.Windows.Forms.Label

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.Container

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.lblTempF = New System.Windows.Forms.Label()
    Me.lblTempC = New System.Windows.Forms.Label()
    Me.hsbTemp = New System.Windows.Forms.HScrollBar()
    Me.lblBlue = New System.Windows.Forms.Label()
    Me.Label2 = New System.Windows.Forms.Label()
    Me.Label3 = New System.Windows.Forms.Label()
    Me.lblRed = New System.Windows.Forms.Label()
    Me.SuspendLayout()
    '
    'lblTempF
    '
    Me.lblTempF.BackColor = System.Drawing.Color.White
    Me.lblTempF.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.lblTempF.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.lblTempF.Location = New System.Drawing.Point(144, 32)
    Me.lblTempF.Name = "lblTempF"
    Me.lblTempF.Size = New System.Drawing.Size(64, 40)
    Me.lblTempF.TabIndex = 2
    Me.lblTempF.Text = "32.0"
    Me.lblTempF.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
    '
    'lblTempC
    '
    Me.lblTempC.BackColor = System.Drawing.Color.White
    Me.lblTempC.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.lblTempC.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.lblTempC.Location = New System.Drawing.Point(144, 144)
    Me.lblTempC.Name = "lblTempC"
    Me.lblTempC.Size = New System.Drawing.Size(64, 40)
    Me.lblTempC.TabIndex = 2
    Me.lblTempC.Text = "0.0"
    Me.lblTempC.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
    '
    'hsbTemp
    '
    Me.hsbTemp.Location = New System.Drawing.Point(32, 96)
    Me.hsbTemp.Maximum = 1209
    Me.hsbTemp.Minimum = -600
    Me.hsbTemp.Name = "hsbTemp"
    Me.hsbTemp.Size = New System.Drawing.Size(232, 24)
    Me.hsbTemp.TabIndex = 3
    Me.hsbTemp.Value = 120
    '
    'lblBlue
    '
    Me.lblBlue.BackColor = System.Drawing.Color.Blue
    Me.lblBlue.Location = New System.Drawing.Point(16, 80)
    Me.lblBlue.Name = "lblBlue"
    Me.lblBlue.Size = New System.Drawing.Size(264, 56)
    Me.lblBlue.TabIndex = 0
    '
    'Label2
    '
    Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Label2.Location = New System.Drawing.Point(40, 40)
    Me.Label2.Name = "Label2"
    Me.Label2.Size = New System.Drawing.Size(96, 24)
    Me.Label2.TabIndex = 4
    Me.Label2.Text = "Fahrenheit"
    Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
    '
    'Label3
    '
    Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
    Me.Label3.Location = New System.Drawing.Point(48, 152)
    Me.Label3.Name = "Label3"
    Me.Label3.Size = New System.Drawing.Size(96, 24)
    Me.Label3.TabIndex = 4
    Me.Label3.Text = "Celsius"
    Me.Label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
    '
    'lblRed
    '
    Me.lblRed.BackColor = System.Drawing.Color.Red
    Me.lblRed.Location = New System.Drawing.Point(16, 80)
    Me.lblRed.Name = "lblRed"
    Me.lblRed.Size = New System.Drawing.Size(264, 56)
    Me.lblRed.TabIndex = 0
    '
    'frmTemp
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(306, 217)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Label3, Me.Label2, Me.lblTempC, Me.hsbTemp, Me.lblTempF, Me.lblBlue, Me.lblRed})
    Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
    Me.Name = "frmTemp"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Temperature Conversion"
    Me.ResumeLayout(False)

  End Sub

#End Region

  Dim IsHot As Boolean

  Private Sub hsbTemp_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles hsbTemp.Scroll
    Dim TempF As Single, TempC As Single
    'Read F and convert to C - divide by 10 needed since Value is tenths of degrees
    TempF = CSng(Val(hsbTemp.Value) / 10)
    'check to see if changed from hot to cold or vice versa
    If IsHot And TempF < 70 Then
      'changed to cold
      IsHot = False
      lblBlue.BringToFront()
      hsbTemp.BringToFront()
    ElseIf Not (IsHot) And TempF >= 70 Then
      'changed to hot
      IsHot = True
      lblRed.BringToFront()
      hsbTemp.BringToFront()
    End If
    lblTempF.Text = Format(TempF, "0.0")
    TempC = (TempF - 32) * 5 / 9
    lblTempC.Text = Format(TempC, "0.0")
  End Sub


  
End Class
