|
|
Title | Make a cricket temperature calculator in Visual Basic 6 |
Description | This example shows how to make a cricket temperature calculator in Visual Basic 6. |
Keywords | cricket, temperature, chirps, silly, game |
Categories | Miscellany, Algorithms, Puzzles and Games |
|
|
This is a silly little temperature calculator based on the fact that a cricket's chirp rate depends on the temperature. The temperature in degrees Fahrenheit is approximately the number of chirps per 15 seconds plus 40.
When the user changes the chirps value, the program determines whether the new value looks like a number. If so, it calculates and displays the temperature. If the value doesn't look like a number, the program displays a blank string.
|
|
Private Sub txtChirps_Change()
Dim chirps As Integer
If IsNumeric(txtChirps.Text) Then
chirps = Val(txtChirps.Text)
lblTemperature.Caption = Format$(chirps + 40, "0")
Else
lblTemperature.Caption = ""
End If
End Sub
|
|
|
|
|
|