try this one

Option Explicit

'If you change this number the control (drag) points get bigger!

Private Const bytControlPointSize As Byte = 2

' The endpoints are points 1 and 4. The control

' points are points 2 and 3.

Private intMaxPoints As Integer

Private sngPointX() As Single

Private sngPointY() As Single

Private MakingNew As Boolean

' The index of the point being dragged.

Private Dragging As Integer

' intCurvinessValue determines the smoothness of the curve.

Private intCurvinessValue As Integer

' t is a value related to the vector tangents.

'For Bezier curves and Hermite curves it's between 0 and 1, but for B-Splines

'it runs between 0 and (intMaxPoints - intCurvinessValue + 2)

Private sngMaxVectorTngnt As Single

' Recursively compute the Blendinging function.

Private Function Blending(ByVal i As Integer, ByVal k As Integer, ByVal t As Single) As Single

Dim sngNumerator As Single

Dim sngDenominator As Single

Dim sngTempValue1 As Single

Dim sngTempValue2 As Single

'You're probably asking waht the heck are knots. Well..it's a math thing

'The blending function B(subscript i,k)(t) are defined recursively in terms of

' a set of "knot values" that make up a "knot vector" --now are you sorry you asked

'Some more math stuff (hopefully won't throw you...)

'B(subscript i,1)(t)=

'

'1 if Knot(i) <= t < Knot(i+ 1)

'1 if Knot(i) <= t <= Knot(i + 1)

' and t = N - k + 2 (where N = number of control points)

'

'0 otherwise

'B(subscript i,k)(t) = (t - Knot(i)) * B(subscript i,k-1)(t) / (Knot(i + k - 1) - Knot(i)) +

' (Knot(i + k) - t) * B(subscript i+1,k-1)(t) / (Knot(i = k) - Knot(i = 1)

'Whew..okay..that's enough math already...

' Base case for the recursive blending

' k is the value for the smoothness

' i is the index of the knot

If k = 1 Then

If (Knot(i) <= t) And (t < Knot(i + 1)) Then

Blending = 1

ElseIf (t = sngMaxVectorTngnt) And (Knot(i) <= t) And (t <= Knot(i + 1)) Then

Blending = 1

Else

Blending = 0

End If

Exit Function

End If

sngDenominator = Knot(i + k - 1) - Knot(i)

If sngDenominator = 0 Then

sngTempValue1 = 0

Else

sngNumerator = (t - Knot(i)) * Blending(i, k - 1, t)

sngTempValue1 = sngNumerator / sngDenominator

End If

sngDenominator = Knot(i + k) - Knot(i + 1)

If sngDenominator = 0 Then

sngTempValue2 = 0

Else

sngNumerator = (Knot(i + k) - t) * Blending(i + 1, k - 1, t)

sngTempValue2 = sngNumerator / sngDenominator

End If

Blending = sngTempValue1 + sngTempValue2

End Function

' Draw the curve on the indicated picture box.

'Note: Called by DrawBspline Sub

Private Sub DrawCurve(pic As PictureBox, start_t As Single, stop_t As Single, intSmoothnessValue As Single)

Dim t As Single

pic.Cls

pic.CurrentX = X(start_t)

pic.CurrentY = Y(start_t)

t = start_t + intSmoothnessValue

Do While t < stop_t

pic.Line -(X(t), Y(t))

t = t + intSmoothnessValue

Loop

pic.Line -(X(stop_t), Y(stop_t))

End Sub

' Return the ith knot value.

Private Function Knot(ByVal i As Integer) As Integer

'See note above about "What's a knot?"

'...but basically don't worry too much about it

If i < intCurvinessValue Then

Knot = 0

ElseIf i <= intMaxPoints Then

Knot = i - intCurvinessValue + 1

Else

Knot = intMaxPoints - intCurvinessValue + 2

End If

End Function

' The parametric function Y(t).

Private Function Y(ByVal t As Single) As Single

'Remember for B-Splines t varies between

' zero and N- k + 2 (where N = Number of points)

Dim i As Integer

Dim value As Single

For i = 0 To intMaxPoints

value = value + sngPointY(i) * Blending(i, intCurvinessValue, t)

Next i

Y = value

End Function

' The parametric function X(t).

Private Function X(ByVal t As Single) As Single

'Remember for B-Splines t varies between

' zero and N- k + 2 (where N = Number of points)

Dim intIndexValue As Integer

Dim sngTempValue As Single

For intIndexValue = 0 To intMaxPoints

sngTempValue = sngTempValue + sngPointX(intIndexValue) * Blending(intIndexValue, intCurvinessValue, t)

Next intIndexValue

X = sngTempValue

End Function

' Use DrawBspline to draw the B-Spline curve.

Private Sub DrawBspline()

'Maybe some more needs to be said

Dim intSmoothnessValue As Single

Dim intIndex As Integer

Dim oldstyle As Integer

If intMaxPoints < 0 Then Exit Sub

MousePointer = vbHourglass

intCurvinessValue = CInt(txtK.Text)

intSmoothnessValue = CSng(txtDt.Text)

sngMaxVectorTngnt = intMaxPoints - intCurvinessValue + 2

DrawCurve picCanvas, 0, sngMaxVectorTngnt, intSmoothnessValue

' Draw the control points.

For intIndex = 0 To intMaxPoints

picCanvas.Line _

(sngPointX(intIndex) - bytControlPointSize, sngPointY(intIndex) - bytControlPointSize)- _

Step(2 * bytControlPointSize, 2 * bytControlPointSize), , BF

Next intIndex

' Connect the control points --

'Note: this draws the dotted lines

' between control points

oldstyle = picCanvas.DrawStyle

picCanvas.DrawStyle = vbDot

picCanvas.CurrentX = sngPointX(0)

picCanvas.CurrentY = sngPointY(0)

For intIndex = 1 To intMaxPoints

picCanvas.Line -(sngPointX(intIndex), sngPointY(intIndex))

Next intIndex

picCanvas.DrawStyle = oldstyle

MousePointer = vbDefault

End Sub

Private Sub cmdExit_Click()

Unload Me 'Outta here!

End

End Sub

' Either collect a new point or select an old point and

' start dragging it.

Private Sub picCanvas_MouseDown(button As Integer, Shift As Integer, X As Single, Y As Single)

Dim i As Integer

' If we are selecting points, do so now.

If MakingNew Then

intMaxPoints = intMaxPoints + 1

ReDim Preserve sngPointX(0 To intMaxPoints)

ReDim Preserve sngPointY(0 To intMaxPoints)

sngPointX(intMaxPoints) = X

sngPointY(intMaxPoints) = Y

picCanvas.Line _

(X - bytControlPointSize, Y - bytControlPointSize)- _

Step(2 * bytControlPointSize, 2 * bytControlPointSize), , BF

If intMaxPoints >= 2 Then cmdGo.Enabled = True

Exit Sub

End If

' Otherwise start dragging a point.

' Find a close point.

For i = 0 To intMaxPoints

If Abs(sngPointX(i) - X) <= bytControlPointSize And _

Abs(sngPointY(i) - Y) <= bytControlPointSize Then Exit For

Next i

If i > intMaxPoints Then Exit Sub

Dragging = i

picCanvas.DrawMode = vbInvert

sngPointX(Dragging) = X

sngPointY(Dragging) = Y

picCanvas.Line _

(sngPointX(Dragging) - bytControlPointSize, sngPointY(Dragging) - bytControlPointSize)- _

Step(2 * bytControlPointSize, 2 * bytControlPointSize), , BF

End Sub

' Continue dragging a point.

Private Sub picCanvas_MouseMove(button As Integer, Shift As Integer, X As Single, Y As Single)

If Dragging < 0 Then Exit Sub

picCanvas.Line _

(sngPointX(Dragging) - bytControlPointSize, sngPointY(Dragging) - bytControlPointSize)- _

Step(2 * bytControlPointSize, 2 * bytControlPointSize), , BF

sngPointX(Dragging) = X

sngPointY(Dragging) = Y

picCanvas.Line _

(sngPointX(Dragging) - bytControlPointSize, sngPointY(Dragging) - bytControlPointSize)- _

Step(2 * bytControlPointSize, 2 * bytControlPointSize), , BF

End Sub

' Finish the drag and redraw the curve.

Private Sub picCanvas_MouseUp(button As Integer, Shift As Integer, X As Single, Y As Single)

If Dragging < 0 Then Exit Sub

picCanvas.DrawMode = vbCopyPen

sngPointX(Dragging) = X

sngPointY(Dragging) = Y

Dragging = -1

DrawBspline 'Redraw B-Spline curve

End Sub

Private Sub CmdGo_Click()

MakingNew = False

cmdNew.Enabled = True

DrawBspline 'Redraw B-Spline curve

End Sub

' Prepare to get new points.

Private Sub CmdNew_Click()

intMaxPoints = -1

cmdGo.Enabled = False

cmdNew.Enabled = False

MakingNew = True

picCanvas.Cls

End Sub

Private Sub Form_Load()

MakingNew = True

intMaxPoints = -1

Dragging = -1

End Sub

' Make the picCanvas as big as possible.

Private Sub Form_Resize()

picCanvas.Move 0, picCanvas.Top, _

ScaleWidth, ScaleHeight - picCanvas.Top

DrawBspline 'Redraw B-Spline curve

End Sub