Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Cipher, Beginners Question

Posted on 1998-10-13
Medium Priority
264 Views
Ok, I have code here that Will have a INputbox pop up and Ask you to enter a word to Cipher, the Only problem is it goes one word at a time.  I want to be able to Cipher a complete word rather than one word at a time, It's a basic Question, I'm only a newbie.

Private Sub cmdCipher_Click()
Dim Letter as String
Letter = Inputbox("Enter a Word To cipher")
Label1.Caption = Label1.Caption & Letter
Label2.Caption = Label2.Caption & Chrs\$(Asc(Letter) + 3)
End Sub

0
Question by:infiniteloop
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 4

Accepted Solution

mcix earned 40 total points
ID: 1439803
Private Sub Command1_Click()
Dim mstrNewWord As String
Dim mstrOldWord  As String
mstrOldWord = InputBox("Enter a Word To cipher")
mstrNewWord = Cipher(mstrOldWord)

End Sub

Public Function Cipher(vstrInWord As String) As String

Dim mintCurrentPosition As Integer
Dim mstrTempWord As String
Dim mstrCurrentCharacter As String
For mintCurrentPosition = 1 To Len(vstrInWord)

mstrCurrentCharacter = Mid\$(vstrInWord, mintCurrentPosition, 1)
mstrTempWord = mstrTempWord & Chr\$(Asc(mstrCurrentCharacter) + 3)

Next
Cipher = mstrTempWord

End Function
0

LVL 1

Expert Comment

ID: 1439804
Try this code:

Text\$ = InputBox\$("Enter text to cipher:")
Label1.Caption = Text\$
Temp\$ = ""    'Clear Temp to prevent problems, extra characters
For i% = 1 to Len(Text\$)       'Loop through all characters
Temp\$ = Temp\$ + Chr\$(Asc(Mid\$(Text\$, i%, 1)) + 3)
Next i%

This should work nicely.
0

LVL 12

Expert Comment

ID: 1439805
Try putting:

Phrase = Msgbox("Enter phrase to cipher:")
Label1.Caption = ""
Label2.Caption = ""
FOR ndx = 1 TO LEN( Phrase )
Letter = MID( Phrase, ndx, 1 )
Label1.Caption = Label1.Caption & Letter
Label2.Caption = Label2.Caption & CHR( ASC( Letter ) + 3 )
NEXT ndx

M

0

LVL 1

Author Comment

ID: 1439806
Damn That was QUICK!!!!!!!!,

Thanks
0

LVL 1

Author Comment

ID: 1439807
Homework eh!! =)

0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). Uâ€¦
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applicâ€¦
###### Suggested Courses
Course of the Month6 days, 16 hours left to enroll