Dragon Curves v2.0
Submitted By:
hemmer
Rating:
Not rated (
Rate It)
VERSION 5.00
Begin VB.Form DragonForm
Caption = "Dragon Curves - Ewan Hemingway - Step 1. Calculate the turns"
ClientHeight = 10200
ClientLeft = 270
ClientTop = 630
ClientWidth = 14700
LinkTopic = "Form1"
ScaleHeight = 10200
ScaleWidth = 14700
Begin VB.CommandButton DrawCurves
Caption = "Draw Curves"
Height = 495
Left = 6840
TabIndex = 1
Top = 360
Width = 2415
End
Begin VB.TextBox Text2
Height = 8895
Left = 240
MultiLine = -1 'True
TabIndex = 4
Top = 960
Width = 14055
End
Begin VB.CommandButton cmdCreateString
Caption = "Create ""Dragon Curves"" string"
Height = 495
Left = 240
TabIndex = 0
Top = 360
Width = 2415
End
Begin VB.Label Label2
Height = 495
Left = 2880
TabIndex = 3
Top = 480
Width = 2895
End
Begin VB.Label Label1
Height = 255
Left = 2880
TabIndex = 2
Top = 0
Width = 2895
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileItz
Caption = "New Number of Iterations"
End
Begin VB.Menu mnuFileExit
Caption = "E&xit"
Shortcut = ^Q
End
End
Begin VB.Menu mnuHelp
Caption = "Help"
Begin VB.Menu mnuHelpHelp
Caption = "Help"
End
Begin VB.Menu mnuHelpAbout
Caption = "About"
End
End
End
Attribute VB_Name = "DragonForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Iterations
Dim initialFold As String
'********************************************
'* Created By: Ewan (Hemmer) Hemingway *
'* Date: 25/06/03 *
'* Email: [[Email Removed]] *
'********************************************
Private Sub cmdCreateString_Click()
Dim StrName As String 'Variable holds the String in Reverse
Dim LengthOfName As Integer 'Holds the length of the String
LengthOfName = 1
StrName = initialFold
Text2.Text = ""
Text2.Text = Text2.Text + initialFold
Call DragonMaker(StrName, LengthOfName)
End Sub
Private Sub DragonMaker(StrName, LengthOfName)
Dim Reverse As String
Me.MousePointer = vbHourglass
For i = 0 To (Iterations - 2)
'The loop starts at the end of the string and works backwards
On Error GoTo error_handler
Text2.Text = Text2.Text + initialFold
For LengthOfName = LengthOfName To 1 Step -1
'The mid function pulls characters out of the String
Reverse = Mid(StrName, LengthOfName, 1)
If Reverse = "l" Then
Reverse = "r"
Else ' reverse it to itz opposite
Reverse = "l"
End If
Text2.Text = Text2.Text + Reverse
Next LengthOfName
LengthOfName = Len(Text2.Text)
StrName = Text2.Text
Next i
Me.MousePointer = vbNormal
Label2.Caption = Str(Len(Text2.Text)) + " folds have been made to get this!"
error_handler:
If Err.Number = 7 Then
MsgBox "Too long for me to cope with!!!!!!!!!!"
Me.MousePointer = vbNormal
Exit Sub
End If
End Sub
Private Sub DrawCurves_Click()
DrawForm.Show
End Sub
Private Sub Form_Load()
Dim fillerVar
Call mnuFileItz_Click
Label:
fillerVar = InputBox("What is the first fold you want to make?", "Fold Query", "l")
If Not IsNumeric(fillerVar) And (LCase(fillerVar) = "l" Or LCase(fillerVar) = "r") Then
initialFold = fillerVar
Else
GoTo Label
End If
fillerVar = Null
End Sub
Private Sub mnuFileExit_Click()
If MsgBox("Do you wish to exit?", vbOKCancel + vbQuestion + vbApplicationModal, "Really Exit?") = vbOK Then
End
End If
End Sub
Public Sub mnuFileItz_Click()
here:
Iterations = InputBox("How many iterations do you wish to have?", "Iterations Enquiry", 7)
If Not IsNumeric(Iterations) Then
MsgBox "Must be a number!"
GoTo here
End If
Label1.Caption = "Iterations: " + Str(Iterations)
Text2.Text = ""
End Sub
Private Sub mnuHelpAbout_Click()
frmAbout.Show
End Sub
Private Sub mnuHelpHelp_Click()
MsgBox ("Dragon curves are created when you continualy fold a piece of paper." + vbCrLf + "You turn the paper on it's side and the pattern you see is a dragon curve." + vbCrLf + "When you can't fold it any more you can calculate what the pattern will be. If when opened, " + vbCrLf + "your paper shows a left, a left, and a right turn (llr), to find the next one: first put a left (l)," + vbCrLf + "then mirror it (rll) and finally reverse ls for rs to get llrllrr." + vbCrLf + "Get it? You can work out the number of turns using the formula '2 to the power of N - 1'")
End Sub
Private Sub Text2_GotFocus()
MsgBox ("I don't want to risk you tampering with the curve data!!")
cmdCreateString.SetFocus
End Sub