I ran this code extensively and checked for several values entered in txtsu, txmo, txtma, txtme, txtve, txtju and txtst. I have found a consistant pattern in the error. When the entered combination is MOON-STRN and whatever be the values of txtmo and txtst, the code gives back correct answers. Examples; txtmo = 4 and txtst = 126 gave output 122 in txtdif. Similarly txtmo = 40 and txtst = 126 gave output 86 in txtdif. Code lines for this step are:-
If lblrotascldplt.Caption = "MOON" Then mo = txtmo.Text
If lblcuconplt.Caption = "STRN" Then st = txtst.Text
diff = st - mo
txtdif.Text = diff
In all other combinations MOON-SUNN, MOON-MERC,MOON-MARS, MOON-VENS, MOON-JUPT and MOON-MOON the code returns the value of txmo with a negative sign preceeding the value of txtmo. Obviously for some reason the program is not reading the value of the other text box as the answer is always a negativised value of txtmo. Examples are tabulated below:-
Value Result Result Comment on Result
entered in txtdif for txtmo.Text=4 in txtdif for txtmo.Text=40
txtsu.Text 34 -4 -40 negativised vale of txtmo
txtma.Text 50 -4 -40 negativised vale of txtmo
txtme.Text 66 -4 -40 negativised vale of txtmo
txtju.Text 95 -4 -40 negativised vale of txtmo
txtve.Text 188 -4 -40 negativised vale of txtmo
txtst.Text 126 122 86 correct calculation
Relevant operative code lines for this calculation for other combinations are given here-under.
I just do not understand why this program is not reading the other text box's values in other equations under other combinations.
If lblrotascldplt.Caption = "MOON" Then mo = txtmo.Text
If lblcuconplt.Caption = "STRN" Then st = txtst.Text
diff = st - mo
txtdif.Text = diff
In all other combinations MOON-SUNN, MOON-MERC,MOON-MARS, MOON-VENS, MOON-JUPT and MOON-MOON the code returns the value of txmo with a negative sign preceeding the value of txtmo. Obviously for some reason the program is not reading the value of the other text box as the answer is always a negativised value of txtmo. Examples are tabulated below:-
Value Result Result Comment on Result
entered in txtdif for txtmo.Text=4 in txtdif for txtmo.Text=40
txtsu.Text 34 -4 -40 negativised vale of txtmo
txtma.Text 50 -4 -40 negativised vale of txtmo
txtme.Text 66 -4 -40 negativised vale of txtmo
txtju.Text 95 -4 -40 negativised vale of txtmo
txtve.Text 188 -4 -40 negativised vale of txtmo
txtst.Text 126 122 86 correct calculation
Relevant operative code lines for this calculation for other combinations are given here-under.
Code:
MOON-SUNN
If lblrotascldplt.Caption = "MOON" Then mo = txtmo.Text
If lblcuconplt.Caption = "SUNN" Then su = txtsu.Text
diff = su - mo
txtdif.Text = diff
MOON-MARS
If lblrotascldplt.Caption = "MOON" Then mo = txtmo.Text
If lblcuconplt.Caption = "MARS" Then ma = txtma.Text
diff = ma - mo
txtdif.Text = diff
MOON-MERC
If lblrotascldplt.Caption = "MOON" Then mo = txtmo.Text
If lblcuconplt.Caption = "MERC" Then mer = txtme.Text
diff = mer - mo
txtdif.Text = diff
MOON-JUPT
If lblrotascldplt.Caption = "MOON" Then mo = txtmo.Text
If lblcuconplt.Caption = "JUPT" Then ju = txtju.Text
diff = ju - mo
txtdif.Text = diff
MOON-VENS
If lblrotascldplt.Caption = "MOON" Then mo = txtmo.Text
If lblcuconplt.Caption = "VENS" Then ve = txtve.Text
diff = ve - mo
txtdif.Text = diff
MOON-STRN
If lblrotascldplt.Caption = "MOON" Then mo = txtmo.Text
If lblcuconplt.Caption = "STRN" Then st = txtst.Text
diff = st - mo
txtdif.Text = diff