I’m trying to produce this equation in VB.NET
h = (sh * s + (dia / 2 (tan(ang))) + ((dia / 2 (tan(ang1))) / 3))

This is where I’d prefer to retrieve the data from.
Sh = sheet height = 1 (can be variable)(data retrieved from textbox)
S = sheets (vertical) = from 1 to 30 (data retrieved from combobox populated by sql server in real format)
Dia = diameter of barrel = from 3 to 50 (data retrieved from combobox populated by sql server in real format)
Ang=angle=between20&80deg(data retrieved from textbox)
Ang1=angle=between20&80deg(data retrieved from textbox)
To explain what this is doing, imagine a pencil sharpened at both ends and you wish to work out the overall length, the barrel I’ve split into sections i.e. sh * s and the height of the top point is one third i.e. ((dia / 2 (tan(ang1))) / 3)), add the height of the barrel and the bottom cone plus one third of the top.
I hope this is clear enough, as you can see explanations aren’t my forte.
Thank you prior for any help.
Ross

The following will implement the formula, however, it won't give you the result you want unless you convert the angle from degrees to radians. The following code does that by multiplying the angle by PI/180. I'll assume the formula is correct (trig was never my strong suit).

Imports System.Math

Public Class Form1

    '                       dia           1          dia
    'h   =   sh * s  +  ------------   +  -  *   ------------
    '                   2 * tan(ang)      3      2 * tan(ang1)

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        Dim sh As Double = CDbl(txtsh.Text)
        Dim s As Double = CDbl(txts.Text)
        Dim dia As Double = CDbl(txtdia.Text)
        Dim ang As Double = CDbl(txtang.Text) * PI / 180.0
        Dim ang1 As Double = CDbl(txtang1.Text) * PI / 180.0

        Dim h As Double

        h = sh * s _
          + dia / (2.0 * Tan(ang)) _
          + dia / (2.0 * Tan(ang1) / 3.0)

        txth.Text = h

    End Sub

End Class

Edited 4 Years Ago by Reverend Jim

This question has already been answered. Start a new discussion instead.