home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 February
/
PCWK0297.iso
/
envelop
/
envelop.5
/
Tools
/
Arsenal
/
apps
/
windchil
/
WINDCHIL.ETO
< prev
next >
Wrap
Text File
|
1996-07-08
|
12KB
|
429 lines
Type WindChill From Application
End Type
Type WindChillForm From SampleMasterForm
Dim Frame1 As New Frame
Dim optMilesPerHour As New OptionButton
Dim optKilometersPerHour As New OptionButton
Dim sbrWindSpeed As New ScrollBar
Dim lblWindSpeed As New Label
Dim Frame2 As New Frame
Dim optCelsius As New OptionButton
Dim optFahrenheit As New OptionButton
Dim sbrTemperature As New ScrollBar
Dim lblTemperature As New Label
Dim btnHelp As New Button
Dim btnClose As New Button
Dim Label3 As New Label
Dim gauTemp As New Gauge
Dim gauWindChill As New Gauge
Dim Label4 As New Label
Dim lblMaxTemp As New Label
Dim Label6 As New Label
Dim lblMinTemp As New Label
Dim lblWindChill As New Label
' METHODS for object: WindChillForm
Sub btnClose_Click()
UnloadForm
End Sub
Sub btnHelp_Click()
Dim message As String
Dim newline As String
newline = Chr$(13) & Chr$(10)
message = "Use the scrollbars to adjust the wind speed and temperature." & newline
message = message & "Click the options buttons to set wind speed and temperature units." & newline
message = message & "Wind chill factor is displayed below scrollbars and in gauge." & newline & newline
message = message & "Clicking the option buttons will convert temperature and wind speed."
InfoBox.Msg(message)
End Sub
Function Celsius2Fahrenheit (C As Integer) As Single
' Convert Celsius to Fahrenheit
Celsius2Fahrenheit = (C + 40) * 9 / 5 - 40
End Function
Sub ComputeWindChill
Dim wind, temp As Single
Dim chill As Integer
' Get the values from the scroll bars
wind = sbrWindSpeed.Value
temp = sbrTemperature.Value
' Update the temperature gauge
gauTemp.Value = sbrTemperature.Value
' Update the temperature caption
If optFahrenheit.Value = True Then
lblTemperature.Caption = sbrTemperature.Value & " F"
Else
lblTemperature.Caption = sbrTemperature.Value & " C"
End If
' Convert to MPH if KPH selected
If optKilometersPerHour.Value = True Then
wind = Kph2Mph(sbrWindSpeed.Value)
End If
' Convert to Fahrenheit if Celsius selected
If optCelsius.Value = True Then
temp = Celsius2Fahrenheit(sbrTemperature.Value)
End If
' Compute wind chill factor
chill = int(91.9 - (91.4 - temp) * ((0.30344 * sqr(wind) - 0.02029 * wind) + 0.47427))
' Convert back to Celsius if necessary
If optCelsius.Value = True Then
chill = Fahrenheit2Celsius(chill)
End If
' Update the windchill gauge
gauWindChill.Value = chill
' Update the windchill label
If optFahrenheit.Value = True Then
lblWindChill.Caption = "Windchill factor is " & Str$(chill) & " F"
Else
lblWindChill.Caption = "Windchill factor is " & Str$(chill) & " C"
End If
End Sub
Sub ExitApplication_Click()
helpfile.Quit
UnloadForm
End Sub
Function Fahrenheit2Celsius (F As Integer) As Single
' Convert Fahrenheit to Celsius
Fahrenheit2Celsius = (F + 40) * 5 / 9 - 40
End Function
Function Kph2Mph (KPH As Integer) As Single
' Convert KPH to MPH
Kph2Mph = KPH / 1.609344
End Function
Sub Load
' Initialize which option buttons default to True
optFahrenheit.Value = True
optMilesPerHour.Value = True
' Initialize the scrollbars
sbrWindSpeed_Change
sbrTemperature_Change
End Sub
Function Mph2Kph (MPH As Integer) As Single
' Convert MPH to KPH
Mph2Kph = MPH * 1.609344
End Function
Sub optCelsius_Click()
Dim temperature As Single
' Convert current temperature to Celsius
temperature = Fahrenheit2Celsius(sbrTemperature.Value)
If temperature < -45.0 Then
temperature = -45.0
End If
' Reset the scrollbar for MPH
sbrTemperature.Min = -45
sbrTemperature.Max = 32
sbrTemperature.Value = temperature
' Update the temperature bar
lblMaxTemp.Caption = "100 C"
lblMinTemp.Caption = "-100 C"
gauTemp.Max = 100
gauTemp.Min = -100
gauWindChill.Max = 100
gauWindChill.Min = -100
' Computing the windchill will update the temperature bar
' values and associated captions.
ComputeWindChill
End Sub
Sub optFahrenheit_Click()
Dim temperature As Single
' Convert current temperature to Fahrenheit
temperature = Celsius2Fahrenheit(sbrTemperature.Value)
' Check for a minimum condition
If temperature < -50.0 Then
temperature = -50.0
End If
' Reset the scrollbar for MPH
sbrTemperature.Min = -50
sbrTemperature.Max = 90
sbrTemperature.Value = temperature
' Update the temperature/windchill gauges
lblMaxTemp.Caption = "150 F"
lblMinTemp.Caption = "-150 F"
gauTemp.Max = 150
gauTemp.Min = -150
gauWindChill.Max = 150
gauWindChill.Min = -150
' Computing the windchill will update the temperature bar
' values and associated captions.
ComputeWindChill
End Sub
Sub optKilometersPerHour_Click()
Dim wind_speed As Single
' Convert current wind speed to KPH
wind_speed = Mph2Kph(sbrWindSpeed.Value)
' Round wind_speed to nearest integer
wind_speed = int(wind_speed + 0.5)
' Reset the scrollbar for MPH
sbrWindSpeed.Min = 8
sbrWindSpeed.Max = 80
sbrWindSpeed.Value = wind_speed
' Update the windspeed label caption
lblWindSpeed.Caption = wind_speed & " KPH"
End Sub
Sub optMilesPerHour_Click()
Dim wind_speed As Single
' Convert current wind speed to MPH
wind_speed = Kph2Mph(sbrWindSpeed.Value)
' Round wind_speed to nearest integer
wind_speed = int(wind_speed + 0.5)
' Reset the scrollbar for MPH
sbrWindSpeed.Min = 5
sbrWindSpeed.Max = 50
sbrWindSpeed.Value = wind_speed
' Update the windspeed label caption
lblWindSpeed.Caption = wind_speed & " MPH"
End Sub
Sub sbrTemperature_Change()
' Compute the wind chill
ComputeWindChill
End Sub
Sub sbrTemperature_Scroll()
' Update the temperature when the scrollbar is moved
sbrTemperature_Change
End Sub
Sub sbrWindSpeed_Change()
Dim ws As String
' Get Wind Speed
ws = sbrWindSpeed.Value
If optMilesPerHour.Value = True Then
lblWindSpeed.Caption = ws & " MPH"
Else
lblWindSpeed.Caption = ws & " KPH"
End If
' Compute the wind chill
ComputeWindChill
End Sub
Sub sbrWindSpeed_Scroll()
' Update the wind speed when the scrollbar is moved
sbrWindSpeed_Change
End Sub
Function TrimString (input_string As String) As String
TrimString = LTrim(RTrim(input_string))
End Function
End Type
Begin Code
' Reconstruction commands for object: WindChill
'
With WindChill
.ModulePath := "base.ebo;win32.ebo;dialogs.ebo;tools.ebo;envelop.ebo;windchil.ebo"
.MainForm := WindChillForm
.Path := "w:\arsenal\apps\windchil\"
.EXEName := "windchil"
.SplashFileName := "C:\envelop\arsenal\apps\windchil\WINDCHIL.BMP"
End With 'WindChill
' Reconstruction commands for object: WindChillForm
'
With WindChillForm
.Caption := "Wind-Chill Application"
.Move(4335, 1800, 7560, 4290)
.SampleDir := "C:\ENVELOP\arsenal\apps\windchil\"
.SampleName := "WINDCHIL"
With .Frame1
.Caption := "Wind Speed"
.ZOrder := 16
.Move(300, 300, 2250, 2100)
End With 'WindChillForm.Frame1
With .optMilesPerHour
.Caption := "Miles/Hour"
.ZOrder := 14
.Move(450, 750, 1950, 300)
.TabStop := True
.Value := True
End With 'WindChillForm.optMilesPerHour
With .optKilometersPerHour
.Caption := "Kilometers/Hour"
.ZOrder := 13
.Move(450, 1050, 1950, 300)
End With 'WindChillForm.optKilometersPerHour
With .sbrWindSpeed
.Caption := "sbrWindSpeed"
.ZOrder := 15
.Move(450, 1500, 1950, 300)
.SmallChange := 1
.LargeChange := 10
.Min := 5
.Max := 50
.Value := 5
.Orientation := "Horizontal"
.Move(450, 1500, 1950, 300)
End With 'WindChillForm.sbrWindSpeed
With .lblWindSpeed
.Caption := "5 MPH"
.ZOrder := 12
.Move(750, 1950, 1350, 300)
.Alignment := "Center"
End With 'WindChillForm.lblWindSpeed
With .Frame2
.Caption := "Temperature"
.ZOrder := 17
.Move(2700, 300, 2250, 2100)
End With 'WindChillForm.Frame2
With .optCelsius
.Caption := "Celsius"
.ZOrder := 10
.Move(2850, 750, 1950, 300)
End With 'WindChillForm.optCelsius
With .optFahrenheit
.Caption := "Fahrenheit"
.ZOrder := 9
.Move(2850, 1050, 1950, 300)
.TabStop := True
.Value := True
End With 'WindChillForm.optFahrenheit
With .sbrTemperature
.Caption := "sbrTemperature"
.ZOrder := 11
.Move(2850, 1500, 1950, 300)
.SmallChange := 1
.LargeChange := 10
.Min := -50
.Max := 90
.Value := 32
.Orientation := "Horizontal"
.Move(2850, 1500, 1950, 300)
End With 'WindChillForm.sbrTemperature
With .lblTemperature
.Caption := "32 F"
.ZOrder := 8
.Move(3150, 1950, 1350, 300)
.Alignment := "Center"
End With 'WindChillForm.lblTemperature
With .btnHelp
.Caption := "Help"
.ZOrder := 7
.Move(300, 3000, 1500, 450)
End With 'WindChillForm.btnHelp
With .btnClose
.Caption := "Close"
.ZOrder := 6
.Move(2400, 3000, 1500, 450)
End With 'WindChillForm.btnClose
With .Label3
.Caption := "Temp"
.ZOrder := 5
.Move(5850, 150, 600, 300)
End With 'WindChillForm.Label3
With .gauTemp
.ZOrder := 18
.Move(6000, 450, 300, 3000)
.Min := -150
.Max := 150
.Value := 32
.Orientation := "Vertical"
.Move(6000, 450, 300, 3000)
End With 'WindChillForm.gauTemp
With .gauWindChill
.ZOrder := 4
.Move(6750, 450, 300, 3000)
.Min := -150
.Max := 150
.Value := 29
.Orientation := "Vertical"
.Move(6750, 450, 300, 3000)
End With 'WindChillForm.gauWindChill
With .Label4
.Caption := "Chill"
.ZOrder := 3
.Move(6600, 150, 450, 300)
End With 'WindChillForm.Label4
With .lblMaxTemp
.Caption := "150 F"
.ZOrder := 19
.Move(5100, 450, 750, 300)
.Alignment := "Right"
End With 'WindChillForm.lblMaxTemp
With .Label6
.Caption := "0"
.ZOrder := 2
.Move(5100, 1800, 750, 300)
.Alignment := "Right"
End With 'WindChillForm.Label6
With .lblMinTemp
.Caption := "-150 F"
.ZOrder := 20
.Move(5100, 3000, 750, 300)
.Alignment := "Right"
End With 'WindChillForm.lblMinTemp
With .lblWindChill
.Caption := "Windchill factor is 29 F"
.ZOrder := 1
.Move(300, 2550, 4650, 300)
.Alignment := "Center"
End With 'WindChillForm.lblWindChill
With .helpfile
.FileName := "C:\ENVELOP\arsenal\apps\windchil\WINDCHIL.hlp"
End With 'WindChillForm.helpfile
End With 'WindChillForm
End Code