Dim UserInput, Action
Dim Length, LengthDone
Dim Output
Dim NewInput As String
Private Sub cmdConvert_Click()
'What should we do with the input?
If optEncode.Enabled = False And optDecode.Enabled = False Then
MsgBox ("Select an action to perform")
Exit Sub
End If
If optEncode.Enabled = True Then
Action = Encode
End If
If optDecode.Enabled = True Then
Action = Decode
End If
'What is the input?
UserInput = txtInput.Text
'How long is the input?
Length = Len(UserInput)
'We should tell the user what they gave us
lblInput.Caption = UserInput
txtInput.Text = ""
LengthDone = 1
'Calculate the ASCII Values
If Action = Encode Then
'For Length = 1 To Length COMMENTED OUT - WILL NOT EXECUTE
Do Until LengthDone = Length
Output = Asc(Left(UserInput, LengthDone)) '+ " "
NewInput = NewInput + Str(Output) '+ " "
LengthDone = LengthDone + 1
'Next COMMENTED OUT - WILL NOT EXECUTE
Loop
End If
'Calculate the text values
If Action = Decode Then
Do Until LengthDone = Length
Output = Chr(Left(UserInput, LengthDone))
NewInput = NewInput + Output
LengthDone = LengthDone + 1
Loop
End If
'Lets show them the output
txtInput.Text = NewInput
'lblInput.Caption = txtInput.Text
'txtInput.Text = Asc(txtInput.Text)
End Sub |