Selecting sketch segment from a user form

I have a user form where the user needs to select a sketch segment. Once selected, you click on accept and some calculations are performed. I'm having the hardest time figuring out the correct way to code this. Below is my first attempt taking some bits of code from a different example I found online.

    Dim swApp                       As SldWorks.SldWorks

    Dim swModel                     As SldWorks.ModelDoc2

    Dim swModelDocExt               As SldWorks.ModelDocExtension

    Dim swSelMgr                    As SldWorks.SelectionMgr

    Dim swSketch                    As SldWorks.Sketch

    Dim seg_selection               As SldWorks.SketchSegment

    'Make classes to listen for events

    Dim WithEvents swDraw As SldWorks.DrawingDoc

    Dim WithEvents swPart As SldWorks.PartDoc

    Dim WithEvents swAssm As SldWorks.AssemblyDoc

Sub UserForm1_Initialize()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swSelMgr = swModel.SelectionManager

    Set swSketchMgr = swModel.SketchManager

    Set swSketch = swModel.SketchManager.ActiveSketch

    swModel.SetAddToDB True

   

    If Not swModel Is nothng Then

        Select Case swModel.GetType

            Case swDocumentTypes_e.swDocPART

                Set swPart = swModel

            Case swDocumentTypes_e.swDocASSEMBLY

                Set swAssm = swModel

            Case swDocumentTypes_e.swDocDRAWING

                Set swDraw = swModel

        End Select

        Set swSelMgr = swModel.SelectionManager

    Else

        MsgBox "Please open the document"

    End If

   

End Sub

Sub HandleSelection()

     While swSelMgr.GetSelectedObjectCount < 1

          DoEvents

     Wend

     Set seg_selection = swSelMgr.GetSelectedObject6(-1)

End Sub

    

Sub SomeCalcs( swSelSpline as SldWorks.SketchSegment)

     boolstatus=GetSplineEndPoints(swSelSpline)

     'rest of code in here is for calculations

End Sub

Function GetSplineEndPoints(segment as SldWorks.SketchSegment) as Boolean

     dim swCurve                                             as SldWorks.Curve

     set swCurve = segment.GetCurve         

End Function

I get an error saying

Object variable or With block variable not set, pointing to this line set swCurve = segment.GetCurve

I defined swCurve and segment is defined in the Function. Some how my code is not seeing my selection.

SolidworksApi macros