Brian: the code I gave you was working out the parts and bights and GCD correctly.
You have stuck some lines of code between the initisialsation of nParts and the calculation of nGCD
[quote]//Math
nParts = val(txtParts.text) * val(txtPasses.text) - (val(txtPasses.text) - val(txtPKType.text) * 2)
nBights = val(txtBights.text) * val(txtPasses.text)
nHalfCycles = (val(txtTotalBights.text) * 2)
nFacets = (val(txtTotalParts.text) -1) * val(txtTotalBights.text)[/quote]
Its here that things go wrong.
nParts was expected to be val(txtParts.text) at the point it starts to work out the nGCD
But your newly inserted code has changed it to nParts = val(txtParts.text) * val(txtPasses.text) - (val(txtPasses.text) - val(txtPKType.text) * 2)
I appreciate you are very very new to coding, but you need to use the debugger
Work through the code one line at a time and look at what happens to the contents of variable as you step through.
Dont just copy and paste a bunch of code and hope for the best.
Get the contents of the INPUT fields into integer variables before you start doing the math.
Check the integer variables hold what it said on screen, using the debugger.
Do the math, and put the results into more integer variables.
At the end, put the results of the integer variables onscreen into labels (or text boxes if you must)
[code]dim nHalfCycles as integer
dim nWraps as integer
dim nGCD as integer
dim nparts as integer
dim nbights as integer
dim A , B ,nRemainder as integer
nParts = val(txtPartsField.text) '8 in example
nBights = val(txtBightsField.text) '5 in example
nHalfCycles = nBights *2
//nGCD
if nBights > nParts then
A = nBights
B = nParts
else
A = nParts
B = nBights
end if
do
nRemainder =a mod b
a = b
b = nRemainder
loop until B=0
nGCD = A
nWraps = nBights - nGCD
nRemainder =nParts mod nBights
//NOW start to work out the values of total cycles, Facets , halfcycles etc.
//Dont change the values in nGCD,nWraps,nRemainder,nBights,nParts : these are finished and ready to use.
[/code]