TizzyT

TempConClone -TizzyT

Jan 5th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.52 KB | None | 0 0
  1. Public Class TempConClone
  2.     Private ConType As Byte
  3.     Private Sub TxtFocus(sender As TextBox, e As EventArgs) Handles C.GotFocus, F.GotFocus, K.GotFocus, R.GotFocus
  4.         If sender Is C Then : ConType = 0
  5.         ElseIf sender Is F Then : ConType = 1
  6.         ElseIf sender Is K Then : ConType = 2
  7.         ElseIf sender Is R Then : ConType = 3
  8.         End If
  9.     End Sub
  10.     Private Sub TxtChanged(sender As TextBox, e As EventArgs) Handles C.TextChanged, F.TextChanged, K.TextChanged, R.TextChanged
  11.         If Double.TryParse(sender.Text, Nothing) Then
  12.             Select Case ConType
  13.                 Case 0 : F.Text = C.Text * 1.8 + 32 : K.Text = C.Text + 273.15 : R.Text = K.Text * (9 / 5)
  14.                 Case 1 : C.Text = (F.Text - 32) / 1.8 : K.Text = C.Text + 273.15 : R.Text = K.Text * (9 / 5)
  15.                 Case 2 : C.Text = K.Text - 273.15 : F.Text = C.Text * 1.8 + 32 : R.Text = K.Text * (9 / 5)
  16.                 Case 3 : K.Text = R.Text * (5 / 9) : C.Text = K.Text - 273.15 : F.Text = C.Text * 1.8 + 32
  17.             End Select
  18.         Else
  19.             Select Case ConType
  20.                 Case 0 : F.Text = String.Empty : K.Text = String.Empty : R.Text = String.Empty
  21.                 Case 1 : C.Text = String.Empty : K.Text = String.Empty : R.Text = String.Empty
  22.                 Case 2 : C.Text = String.Empty : F.Text = String.Empty : R.Text = String.Empty
  23.                 Case 3 : C.Text = String.Empty : F.Text = String.Empty : K.Text = String.Empty
  24.             End Select
  25.         End If
  26.     End Sub
  27. End Class
Advertisement
Add Comment
Please, Sign In to add comment