VERSION 5.00
Begin VB.Form frmACSL3
Caption = “COMMACK HS ACSL Program 3 - Senior -
STRINGS"
ClientHeight = 4110
ClientLeft = 165
ClientTop = 750
ClientWidth = 5865
LinkTopic = "Form1"
ScaleHeight = 4110
ScaleWidth = 5865
StartUpPosition = 3 'Windows Default
Begin VB.Frame fraTxtAnswer
Caption = "Answer"
BeginProperty Font
Name = "Trebuchet MS"
Size =
12
Charset = 0
Weight = 400
Underline = 0
'False
Italic = 0
'False
Strikethrough = 0
'False
EndProperty
Height = 1095
Left = 360
TabIndex = 3
Top = 1080
Width = 5175
Begin VB.Label lblAnswer
Alignment = 2
'Center
BeginProperty Font
Name = "Courier New"
Size = 14.25
Charset = 0
Weight = 400
Underline = 0
'False
Italic = 0
'False
Strikethrough = 0
'False
EndProperty
Height = 615
Left = 120
TabIndex = 4
Top = 360
Width = 4935
End
End
Begin VB.ListBox lst1
Height = 1035
Left =
0
Sorted = -1
'True
TabIndex = 2
Top = 3000
Visible = 0
'False
Width = 615
End
Begin VB.CommandButton cmdGo
Caption = "&FIGURE IT OUT!"
Default = -1
'True
Height = 615
Left = 885
TabIndex = 1
Top = 2400
Width = 4095
End
Begin VB.TextBox txtInput
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0
'False
Italic = 0
'False
Strikethrough = 0
'False
EndProperty
Height = 495
Left = 585
TabIndex = 0
Top = 480
Width = 4695
End
Begin VB.Menu mnuFile
Caption = "File"
Begin VB.Menu mnuSolve
Caption = "Solve!"
End
Begin VB.Menu mnuExit
Caption = "Exit"
End
End
Begin VB.Menu mnuInfo
Caption = "Information"
Begin VB.Menu mnuAbout
Caption = "About"
Shortcut = {F1}
End
End
End
Attribute VB_Name = "frmACSL3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private strInput, strIt, temp As String
Private lines() As String
Private Sub cmdGo_Click()
strInput = Trim$(txtInput.Text)
lines = Split(strInput, "/")
strIt = lines(UBound(lines))
Dim myString As String
myString = strIt
For k = 0 To UBound(lines) - 1
dirs = Split(lines(k), "-")
If dirs(0) = "RC" Then myString = RC(myString, Val(dirs(1)))
If dirs(0) = "LC" Then myString = LC(myString, Val(dirs(1)))
If dirs(0) = "RS" Then myString = RS(myString, Val(dirs(1)))
If dirs(0) = "LS" Then myString = LS(myString, Val(dirs(1)))
If dirs(0) = "MC" Then myString = MC(myString,
Val(Mid$(dirs(1), 1, 1)), Val(Mid$(dirs(1), 2, 1)), Val(Mid$(dirs(1), 3, 1)),
Mid$(dirs(1), 4, 1))
If dirs(0) = "REV" Then myString = REV(myString,
Val(Mid$(dirs(1), 1, 1)), Val(Mid$(dirs(1), 2, 1)))
If dirs(0) = "SWAP" Then myString = SWAP(myString,
Val(Mid$(dirs(1), 1, 1)), Val(Mid$(dirs(1), 2, 1)), Val(Mid$(dirs(1), 3, 1)))
If dirs(0) = "SORT" Then myString = SORT(myString,
Val(Mid$(dirs(1), 1, 1)), Val(Mid$(dirs(1), 2, 1)), Mid$(dirs(1), 3, 1))
Next k
lblAnswer.Caption = myString
End Sub
Private Function RC(ByRef s As String, ByVal
num As Integer) As String
temp = Right$(s, num)
s
= temp & s
RC
= Left$(s, Len(s) - num)
End Function
Private Function LC(ByRef s As String, ByVal
num As Integer) As String
temp = Left$(s, num)
s
= s & temp
LC
= Right$(s, Len(s) - num)
End Function
Private Function RS(ByRef s As String, ByVal
num As Integer) As String
s
= Left$(s, Len(s) - num)
RS
= String(num, "#") & s
End Function
Private Function LS(ByRef s As String, ByVal
num As Integer) As String
s
= Right$(s, Len(s) - num)
LS
= s & String(num, "#")
End Function
Private Function MC(ByRef s As String, ByVal
start As Integer, ByVal length As Integer, ByVal num As Integer, ByRef sDir As
String) As String
Dim myTemp As String
myTemp = Mid$(s, start, length)
If
sDir = "L" Then myTemp = LC(myTemp, num)
If
sDir = "R" Then myTemp = RC(myTemp, num)
str1 = Left$(s, start - 1)
str2 = Mid$(s, start + length, Len(s) - start - length + 1)
MC
= str1 & myTemp & str2
End Function
Private Function REV(ByRef s As String, ByVal
start As Integer, ByVal length As Integer) As String
Dim myTemp As String
myTemp = StrReverse(Mid$(s, start, length))
str1 = Left$(s, start - 1)
str2 = Mid$(s, start + length, Len(s) - start - length + 1)
REV = str1 & myTemp & str2
End Function
Private Function SWAP(ByRef s As String,
ByVal start As Integer, ByVal length As Integer, ByVal position As Integer) As
String
Dim piece1, piece2 As String
piece1 = Mid$(s, start, length)
piece2 = Mid$(s, position, length)
Mid$(s, start, length) = piece2
Mid$(s, position, length) = piece1
SWAP = s
End Function
Private Function SORT(ByRef s As String,
ByVal start As Integer, ByVal length As Integer, ByRef sMode)
For i = start To start + length - 1
lst1.AddItem (Mid$(s, i, 1))
Next i
Dim tStr As String
If
sMode = "D" Then
For i = lst1.ListCount - 1 To 0 Step -1
tStr = tStr & lst1.List(i)
Next i
Else
For i = 0 To lst1.ListCount - 1
tStr = tStr & lst1.List(i)
Next i
End If
Mid$(s, start, length) = tStr
lst1.Clear
SORT = s
End Function