aka ibebak
Paragon
We're moving quickly in my computer programming class, I've developed my own style of coding, and my teacher says what I did today is a bit advanced, so I'll post a small mini-tutorial for anyone interested in learning visual basic.
What this does is convert cm to inches.
Variables used:
Switch: - Controls the radio button selection of each type of measurement; ie: Inches or Cm.
decMeasurement - Grabs and stores the measurement inputted in the textbox on the form.
decFinalOutput - The final converted number.
Just take a look at the code, it's pretty self-explanatory,
What this does is convert cm to inches.
Variables used:
Switch: - Controls the radio button selection of each type of measurement; ie: Inches or Cm.
decMeasurement - Grabs and stores the measurement inputted in the textbox on the form.
decFinalOutput - The final converted number.
Just take a look at the code, it's pretty self-explanatory,
Code:
'Connor L.
'3/29/2012
'Program 4 - Variables
Public Class frmMain
Dim switch As Integer
Private Sub radInches_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radInches.CheckedChanged
lblMeasurement.Text = "Centimeters:"
switch = "1"
End Sub
Private Sub radCentimeters_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles radCentimeters.CheckedChanged
lblMeasurement.Text = "Inches:"
switch = "2"
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim decMeasurement As Decimal
Dim decFinalOutput As Decimal
decMeasurement = Val(Me.txtInput.Text)
If switch = 1 Then
decFinalOutput = decMeasurement * 0.393700787
ElseIf switch = 2 Then
decFinalOutput = decMeasurement * 2.54
End If
lblResult.Text = "The measurement is " & decFinalOutput & "."
End Sub
End Class







