Question about classes

  • Thread starter Thread starter AndyNakamura
  • Start date Start date
A

AndyNakamura

Guest
I'm a bit embarrassed to be asking this because I ought to be able to get an answer off the internet.
I'm writing a windows desktop app that uses a lot of different calculations that I have just been putting in a module:

Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim dblHelixDegrees As Double
Dim dblDiameter As Double = CDbl(txtDia.Text)
Dim dblPitch As Double = CDbl(txtPitch.Text)

dblHelixDegrees = GetHelixAngle(dblDiameter, dblPitch)

txtHelix.Text = CStr(dblHelixDegrees)
End Sub
End Class

Imports System.Math
Module modCalcs
Public Function GetHelixAngle(dblDia As Double, dblPitch As Double) As Double

Dim dblCircumference As Double
Dim dblHelixRadians As Double
Dim dblHelixDegrees As Double

dblCircumference = PI * dblDia
dblHelixRadians = Atan(dblPitch / dblCircumference) 'helix angel radians
dblHelixDegrees = dblHelixRadians * (180 / PI)

Return dblHelixDegrees
End Function
End Module
This one is straightforward requiring just two variables.
Anyway, I thought maybe I ought to learn how to use classes to make the code more readable and up to date.
But when I try to search about classes I only seem to find examples of "Employee" or "Car" or "Cat" Classes.
Anyone willing to give me a guidance on converting the above module as a class?
Or maybe a class is not the right thing for this instance?

Continue reading...
 
Back
Top