Word-Scrambler


VB Home | Word-Scrambler | My Email

'Language: VisualBasic 6.0
'Author: Alex Karlov
'Created Date: 08/12/2003
'Last Modified Date: 08/18/2003
'Version: 1.3


'Global Variables Dim intRot As Integer Dim itnLen As Integer
Private Sub Command1_Click() 'Scramble command 'Local Variables Dim strWords As String Dim intCounter As Integer Dim strAsc, strWords2 Dim myArr() If Option1.Value = True Then 'Initialize Variables intRot = Combo1.Text ElseIf Option2.Value = True Then intRot = Combo2.Text End If itnLen = Len(Text1.Text) strWords = "" 'Redimention an Array ReDim myArr(itnLen) 'Processing the letteres For intCounter = 1 To itnLen Step 1 strWords = Mid(Text1.Text, intCounter, 1) myArr(intCounter - 1) = strWords If Option1.Value = True Then If (Asc(myArr(intCounter - 1)) = 13) Or (Asc(myArr(intCounter - 1)) = 10) Or ((Asc(myArr(intCounter - 1)) > 31) And (Asc(myArr(intCounter - 1)) < 65)) Then strAsc = Asc(myArr(intCounter - 1)) Else strAsc = Asc(myArr(intCounter - 1)) + intRot End If ElseIf Option2.Value = True Then 'If Carriage Return or End of Line If (Asc(myArr(intCounter - 1)) = 13) Or (Asc(myArr(intCounter - 1)) = 10) Or ((Asc(myArr(intCounter - 1)) > 31) And (Asc(myArr(intCounter - 1)) < 65)) Then strAsc = Asc(myArr(intCounter - 1)) Else strAsc = Asc(myArr(intCounter - 1)) + intRot 'If Capital letter make sure that it will be replaced by other letter If (Asc(myArr(intCounter - 1)) > 64) And (Asc(myArr(intCounter - 1)) < 91) Then If strAsc > 90 Then intRot1 = strAsc - 90 strAsc = 64 + intRot1 End If End If 'If small case letter make sure that it will be replaced by other letter If (Asc(myArr(intCounter - 1)) > 96) And (Asc(myArr(intCounter - 1)) < 123) Then If strAsc > 122 Then intRot1 = strAsc - 122 strAsc = 96 + intRot1 End If End If End If End If strWords2 = strWords2 & Chr(strAsc) Text2.Text = strWords2 Next End Sub
Private Sub Command2_Click() End End Sub
Private Sub Command3_Click() 'Unscramble command 'Local Variables Dim strWords As String Dim intCounter As Integer Dim strAsc, strWords2 Dim myArr1 If Option1.Value = True Then 'Initialize Variables intRot = Combo1.Text ElseIf Option2.Value = True Then intRot = Combo2.Text End If itnLen = Len(Text2.Text) strWords = "" 'Redimention an Array ReDim myArr1(itnLen) 'Processing the letters For intCounter = 1 To itnLen Step 1 strWords = Mid(Text2.Text, intCounter, 1) myArr1(intCounter - 1) = strWords If Option1.Value = True Then If (Asc(myArr1(intCounter - 1)) = 13) Or (Asc(myArr1(intCounter - 1)) = 10) Or ((Asc(myArr1(intCounter - 1)) > 31) And (Asc(myArr1(intCounter - 1)) < 65)) Then strAsc = Asc(myArr1(intCounter - 1)) Else strAsc = Asc(myArr1(intCounter - 1)) - intRot End If ElseIf Option2.Value = True Then 'If Carriage Return or End of Line If (Asc(myArr1(intCounter - 1)) = 13) Or (Asc(myArr1(intCounter - 1)) = 10) Or ((Asc(myArr1(intCounter - 1)) > 31) And (Asc(myArr1(intCounter - 1)) < 65)) Then strAsc = Asc(myArr1(intCounter - 1)) Else strAsc = Asc(myArr1(intCounter - 1)) - intRot 'If Capital case letter If (Asc(myArr1(intCounter - 1)) > 64) And (Asc(myArr1(intCounter - 1)) < 91) Then If strAsc <= 64 Then intRot1 = 64 - strAsc strAsc = 90 - intRot1 End If End If 'If small case letter If (Asc(myArr1(intCounter - 1)) > 96) And (Asc(myArr1(intCounter - 1)) < 123) Then If strAsc <= 96 Then intRot1 = 96 - strAsc strAsc = 122 - intRot1 End If End If End If End If strWords2 = strWords2 & Chr(strAsc) Text4.Text = strWords2 Next End Sub
Private Sub Form_Load() 'Local Variables Dim cnt As Integer For cnt = 1 To 26 Step 1 Combo1.AddItem cnt Next End Sub
Private Sub Option1_Click() If Option1.Value = True Then Option2.Value = False End If If Not Text2.Text = "" Then Text2.Text = "" End If If Not Text4.Text = "" Then Text4.Text = "" End If End Sub
Private Sub Option2_Click() If Option2.Value = True Then Option1.Value = False End If If Not Text2.Text = "" Then Text2.Text = "" End If If Not Text4.Text = "" Then Text4.Text = "" End If End Sub