delta to wye and v.v
TRANSCRIPT
8/20/2019 Delta to Wye and v.v
http://slidepdf.com/reader/full/delta-to-wye-and-vv 1/4
Public Class frmTrans Function DtoY(ByRef L As Double, ByRef M As Double, ByRef N As Double) As Double
Return Math.Round(L * M / (L + M + N), 4) 'delta to wye End Function Function YtoD(ByRef L As Double, ByRef M As Double, ByRef N As Double) As Double
Return Math.Round((L * M) + (M * N) + (N * L) / (L), 4) 'wye to delta
End Function Sub labelchanger(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
_rdbDelta.CheckedChanged, rdbWye.CheckedChanged, btnReset.Click
If sender Is rdbDelta Then
Call change("R1", "R2", "R3", "Ra", "Rb", "Rc")ElseIf sender Is rdbWye Then
Call change("Ra", "Rb", "Rc", "R1", "R2", "R3")
End If
End Sub
Sub change(ByRef In1 As String, ByRef In2 As String, ByVal In3 As String, ByVal Out1As String, ByVal Out2 As String, ByVal Out3 As String)
lblIn_1.Text = In1lblIn_2.Text = In2
lblIn_3.Text = In3
lblOut_1.Text = Out1lblOut_2.Text = Out2
lblOut_3.Text = Out3End Sub
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.ClickIf rdbDelta.Checked Xor rdbWye.Checked Then
Try
If txtin_1.Text > 0 And txtin_2.Text > 0 And txtin_3.Text > 0 Then Dim R1 As Double = txtin_1.TextDim R2 As Double = txtin_2.TextDim R3 As Double = txtin_3.Text
If rdbDelta.Checked Then
8/20/2019 Delta to Wye and v.v
http://slidepdf.com/reader/full/delta-to-wye-and-vv 2/4
txtout_1.Text = DtoY(R1, R2, R3)txtout_2.Text = DtoY(R2, R3, R1)txtout_3.Text = DtoY(R3, R1, R2)
ElseIf rdbWye.Checked Then txtout_1.Text = YtoD(R1, R2, R3)txtout_2.Text = YtoD(R2, R3, R2)txtout_3.Text = YtoD(R3, R2, R1)
End If ElseIf txtin_1.Text <= 0 Then
MsgBox("Please enter values greater than zero ONLY!", vbOK +vbExclamation, "Input Error!")
txtin_1.Clear()txtin_1.Focus()
ElseIf txtin_2.Text <= 0 Then MsgBox("Please enter values greater than zero ONLY!", vbOK +
vbExclamation, "Input Error!")
txtin_2.Clear()txtin_2.Focus()
ElseIf txtin_3.Text <= 0 Then MsgBox("Please enter values greater than zero ONLY!", vbOK +
vbExclamation, "Input Error!")txtin_3.Clear()txtin_3.Focus()
ElseIf txtin_1.Text <= 0 And txtin_2.Text <= 0 And txtin_3.Text <= 0 Then MsgBox("Please enter values greater than zero ONLY!", vbOK +
vbExclamation, "Input Error!")
txtin_1.Clear()txtin_2.Clear()txtin_3.Clear()txtin_1.Focus()
End If Catch Overflow As OverflowException
MsgBox("Overflow Exception has occured! Please check input values", vbOK
+ vbCritical, "Error!")
Catch InvalidCast As InvalidCastException MsgBox("Please enter numeric values only!", vbOK + vbCritical, "Error!")
Catch ex As Exception
MsgBox(ex.Message, vbOK + vbCritical, "Error!")End Try
Else
MsgBox("Please select a transformation mode.", vbOK + vbCritical, "SelectionError")
End If
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnReset.Click
txtin_1.Clear()txtin_2.Clear()txtin_3.Clear()
txtout_1.Clear()txtout_2.Clear()txtout_3.Clear()
rdbDelta.Checked = False rdbWye.Checked = False txtin_1.Focus()lblIn_1.Text = ""
8/20/2019 Delta to Wye and v.v
http://slidepdf.com/reader/full/delta-to-wye-and-vv 3/4
lblIn_2.Text = "" lblIn_3.Text = "" lblOut_1.Text = "" lblOut_2.Text = "" lblOut_3.Text = ""
End Sub
Private Sub frmTrans_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim intresponse As Integer = MsgBox("Are you sure to quit?", vbYesNoCancel +vbQuestion, "Quit")
If intresponse = vbYes Then e.Cancel = False
Else e.Cancel = True
End If
End Sub
Sub NoAlphabet(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles _
txtin_1.KeyPress, txtin_2.KeyPress, txtin_3.KeyPress
If sender Is txtin_1 Or sender Is txtin_2 Or sender Is txtin_3 Then
If AscW(e.KeyChar) > 45 And AscW(e.KeyChar) < 58 Or AscW(e.KeyChar) = 8 Then Else
e.KeyChar = Nothing
End If End If
End Sub
Sub ColorChanger(ByVal sender As Object, ByVal e As System.EventArgs) Handles _btnCompute.MouseHover, btnReset.MouseHover, lblIn_1.MouseHover,
txtin_1.MouseHover, Me.MouseHover
If sender Is btnCompute Then
btnCompute.BackColor = Color.AliceBluebtnReset.BackColor = Color.BlanchedAlmond
ElseIf sender Is btnReset Then
btnReset.BackColor = Color.AliceBluebtnCompute.BackColor = Color.BlanchedAlmond
ElseIf sender Is lblIn_1 Then lblIn_1.BackColor = Color.Aqua
lblIn_2.BackColor = Color.ChartreuselblIn_3.BackColor = Color.Gainsboro
ElseIf sender Is txtin_1 Then
txtin_1.BackColor = Color.Red
txtin_2.BackColor = Color.Orangetxtin_3.BackColor = Color.Yellowtxtout_1.BackColor = Color.Green
txtout_2.BackColor = Color.Bluetxtout_3.BackColor = Color.IndigoMe.BackColor = Color.Violet
ElseIf sender Is Me Then Me.BackColor = Color.LightGoldenrodYellowrdbDelta.BackColor = Color.LightSeaGreenrdbWye.BackColor = Color.LightSkyBlue
8/20/2019 Delta to Wye and v.v
http://slidepdf.com/reader/full/delta-to-wye-and-vv 4/4
End If End Sub Sub ColorDefault(ByVal sender As Object, ByVal e As System.EventArgs) Handles _
btnCompute.MouseLeave, btnReset.MouseLeave, lblIn_1.MouseLeave,txtin_1.MouseLeave, Me.MouseLeave
If sender Is btnCompute Then btnCompute.BackColor = Color.Empty
btnReset.BackColor = Color.EmptyElseIf sender Is btnReset Then
btnReset.BackColor = Color.EmptybtnCompute.BackColor = Color.Empty
ElseIf sender Is lblIn_1 Then lblIn_1.BackColor = Color.Empty
lblIn_2.BackColor = Color.EmptylblIn_3.BackColor = Color.Empty
ElseIf sender Is txtin_1 Then
txtin_1.BackColor = Color.Emptytxtin_2.BackColor = Color.Emptytxtin_3.BackColor = Color.Emptytxtout_1.BackColor = Color.Emptytxtout_2.BackColor = Color.Emptytxtout_3.BackColor = Color.EmptyMe.BackColor = Color.Empty
ElseIf sender Is Me Then Me.BackColor = Color.WhiterdbDelta.BackColor = Color.Empty
rdbWye.BackColor = Color.EmptyEnd If
End Sub
End Class