Solved

Cipher, Beginners Question

Posted on 1998-10-13
5
256 Views
Last Modified: 2010-04-30
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


Thanks in advance
0
Comment
Question by:infiniteloop
5 Comments
 
LVL 4

Accepted Solution

by:
mcix earned 10 total points
Comment Utility
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

by:cvidler
Comment Utility
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

by:mark2150
Comment Utility
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

Let me know what grade you get on your homework...

M

0
 
LVL 1

Author Comment

by:infiniteloop
Comment Utility
Damn That was QUICK!!!!!!!!,

Thanks
0
 
LVL 1

Author Comment

by:infiniteloop
Comment Utility
Homework eh!! =)


0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Window placement 17 64
Use Multiple Forms 4 38
VB6 Compile Compatibility Issue 4 25
message box in access 4 33
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now