+ Reply to Thread
Results 1 to 8 of 8

Help with loops & arrays for encrypt/decrypt program

  1. #1
    Registered User
    Join Date
    09-27-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Help with loops & arrays for encrypt/decrypt program

    Hi all, I am new to this forum so let me go ahead and apologize if I have titled this thread wrong or if I need to be more descriptive. Please just say so and I will do my best to adhere to the way yall do things around here! no problem!

    I am working on a encrypt/decrypt program as I am trying to teach myself VBA. Earlier I created a few programs to calculate income tax on a principal, and then I created a program that counts a number of integers that occur in a string.. however neither of those did I have to use arrays. So I am looking for some guidance.

    What I am trying to do is take a 4 digit number and encrypt it by replacing each digit with the sum of it plus a number (i.e. 7) modulus 10. Then I am going to try to further encrypt it one more step to where I will swap the digits around (i.e. swap the 1st and 3rd, and the 2nd and 4th).

    I have looked around online and in a text I bought and I am pretty sure I have to store the 4 values as arrays and put it within a loop for extracting the values using something along the lines of the MID function? Whatever that is, I wasn't able to really understand what it does.

    Anyway, this is kind of what I have... its obviously not correct though as it is not running. I am hoping someone could just guide me as to what I need to adjust. Sorry if my coding is redundant... I am a noob and trying my best through what I find online.

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    09-27-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Help with loops & arrays for encrypt/decrypt program

    anyone?

  3. #3
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Help with loops & arrays for encrypt/decrypt program

    Give this a try

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  4. #4
    Registered User
    Join Date
    09-27-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Help with loops & arrays for encrypt/decrypt program

    Quote Originally Posted by mike7952 View Post
    Give this a try

    Please Login or Register  to view this content.
    Hi Mike, thanks for the help. I understand the logic of your code, however I am not too sure how I would adjust it to work with my CommandButton1 as in my original sample code. Any suggestions? My excel window set up for this code looks like this.
    Attached Images Attached Images

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Help with loops & arrays for encrypt/decrypt program

    Is this homework?

  6. #6
    Registered User
    Join Date
    09-27-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Help with loops & arrays for encrypt/decrypt program

    Quote Originally Posted by mike7952 View Post
    Is this homework?
    If only, taking a class on this would be much easier than teaching myself. However going back to school would be a stretch at my age.

  7. #7
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Help with loops & arrays for encrypt/decrypt program

    try this

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    09-27-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Help with loops & arrays for encrypt/decrypt program

    Quote Originally Posted by mike7952 View Post
    try this

    Please Login or Register  to view this content.
    I appreciate the help, Mike. I should have no problem figuring out how to reverse this and code the decrypt command button now. Thank you for your help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1