by Jake Code (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 18th December 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code is a metric converter, it converts the lot.
API Declarations
'clicked everything on screen is cleared.'When the exit button is pressed the program is exited
'This is the code that coverts Kilometres to Miles
'The cString code tells the user what has been converted
'This is the code that coverts Litres to Imperial Gallons
'The cString code tells the user what has been converted
'This is the code that coverts Metres to Yards
'The cString code tells the user what has been converted
'This is the code that coverts Metres to Yards
'The cString code tells the user what has been converted
'This is the code that coverts Milimetres to Inches
'The cString code tells the user what has been converted
'This code contains all the information for the Start Up box
'Input box and icons. It also has all the code that stops the
'User from putting numbers higher than 32000.9999999 and it also
'stops the user from putting a number such as - 40. And it stops
'letters from being entered aswell.
Dim sInput, sOutput As Single
Dim vInput As Variant
Dim lInputFlag, lInputflag2, lloopflag As Boolean
Dim cString1, Cstring2, cString3, cString4, cString5 As String
Dim cInput1, cInput2, cOutput As String
Private Sub cmdClear_Click()
lblOutput = ""
cmdMetres.Visible = False
cmdKilometres.Visible = False
cmdMillimetres.Visible = False
cmdGallons.Visible = False
cmdClear.Visible = False
cmdStart.Visible = True
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdKilometres_Click()
sOutput = sInput / 0.625
sOutput = Round(sOutput, 2)
lblOutput = sOutput
Cstring2 = " Kilometres "
cString1 = CStr(sInput)
cString4 = CStr(sOutput)
cString5 = " Miles. "
cString3 = " represents "
lblOutput = cString1 + Cstring2 + cString3 + cString4 _
+ cString5
End Sub
Private Sub cmdGallons_Click()
sOutput = sInput * 0.225
sOutput = Round(sOutput, 2)
lblOutput = sOutput
Cstring2 = " Litres "
cString1 = CStr(sInput)
cString4 = CStr(sOutput)
cString5 = " Imperial gallons. "
cString3 = " Represents "
lblOutput = cString1 + Cstring2 + cString3 + cString4 _
+ cString5
End Sub
Private Sub cmdMetres_Click()
sOutput = sInput * 1.08
sOutput = Round(sOutput, 2)
lblOutput = sOutput
Cstring2 = " Metres "
cString1 = CStr(sInput)
cString4 = CStr(sOutput)
cString5 = " Yards. "
cString3 = " Represents "
lblOutput = cString1 + Cstring2 + cString3 + cString4 _
+ cString5
End Sub
Private Sub cmdMillimetres_Click()
sOutput = sInput / 25.4
sOutput = Round(sOutput, 2)
lblOutput = sOutput
Cstring2 = " Millimetres "
cString1 = CStr(sInput)
cString4 = CStr(sOutput)
cString5 = " Inches. "
cString3 = " Represents "
lblOutput = cString1 + Cstring2 + cString3 + cString4 _
+ cString5
End Sub
Private Sub cmdStart_Click()
lInputFlag = True
lInputflag2 = True
Do While lInputFlag = True
vInput = InputBox("Please enter your number...", " Enter Input")
If IsNumeric(vInput) Then
If vInput > 0 Then
If vInput > 32000.9999999 Then
MsgBox "Your input was to high"
Else
lInputFlag = False
End If
Else
MsgBox "Your input was to Low"
End If
Else
MsgBox "Your input wasn't a number....", vbOKOnly, "Non-numeric Input"
lInputflag2 = False
lInputFlag = False
End If
Loop
If lInputflag2 = True Then
sInput = CSng(vInput)
cmdMetres.Visible = True
cmdMillimetres.Visible = True
cmdKilometres.Visible = True
cmdGallons.Visible = True
cmdClear.Visible = True
cmdStart.Visible = False
End If
End Sub
Private Sub Form_Load()
cmdMetres.Visible = False
cmdMillimetres.Visible = False
cmdKilometres.Visible = False
cmdGallons.Visible = False
cmdClear.Visible = False
cmdStart.Visible = True
End Sub