VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 3195 ClientLeft = 60 ClientTop = 345 ClientWidth = 4680 LinkTopic = "Form1" ScaleHeight = 3195 ScaleWidth = 4680 StartUpPosition = 3 'Windows Default Begin VB.TextBox Text1 Height = 375 Left = 3960 TabIndex = 1 Text = "4" Top = 480 Width = 495 End Begin VB.CommandButton Command1 Caption = "Command1" Height = 375 Left = 3480 TabIndex = 0 Top = 0 Width = 1215 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Sub hilbert(x0, y0, xis, xjs, yis, yjs, n) '/* x0 and y0 are the coordinates of the bottom left corner */ '/* xis & xjs are the i & j components of the unit x vector this frame */ '/* similarly yis and yjs */ If (n < 0) Then Line -(x0 + (xis + yis) / 2, y0 + (xjs + yjs) / 2) Else Call hilbert(x0, y0, yis / 2, yjs / 2, xis / 2, xjs / 2, n - 1) Call hilbert(x0 + xis / 2, y0 + xjs / 2, xis / 2, xjs / 2, yis / 2, yjs / 2, n - 1) Call hilbert(x0 + xis / 2 + yis / 2, y0 + xjs / 2 + yjs / 2, xis / 2, xjs / 2, yis / 2, yjs / 2, n - 1) Call hilbert(x0 + xis / 2 + yis, y0 + xjs / 2 + yjs, -yis / 2, -yjs / 2, -xis / 2, -xjs / 2, n - 1) End If End Sub Private Sub Command1_Click() Call hilbert(0, 0, 3000, 0, 0, 3000, Text1) End Sub