Results 1 to 13 of 13

Thread: ascii in order

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    22

    ascii in order

    sigh yet another dead end of searching....I can't even begin to start this one, I am stumped....SO I came here...

    what I am looking for is....

    a code that will change the letter in a text box +1 (including A - Z 'upper and lower case' ,numbers/charaters ) pretty much anything that is "normally used for typing" I want it to go off in order.

    after it gets to the last one in the order it goes back to the first keeps it in the first spot and does the same loop with the seccond spot, then changes the first one to the seccond in the loop, etc....

    example:
    A
    B
    .(skip ahead)
    .(skip ahead)
    Z
    AA
    AB
    .(skip ahead)
    .(skip ahead)
    BA
    BB

    if you don't get that then I can explain it better.

    I only need the basic code and idea of how to do it, not the entire thing, I know it will be long...maybe lol.

  2. #2
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: ascii in order

    password cracker ?

    you know theres 255 characters, so to go past a set of about 8+ long will take you a long time.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2006
    Posts
    22

    Re: ascii in order

    no, I was just messing with text and etc, and I wanted to make a list of letters in order maybe mess with encoding, ASCII is a low point for me...I can never get anything to work with letters (not text1.text= either) but stuff like finding the letter and changing it up once, etc etc...I want to see code, this will be an example of every ASCII think I will need......I don't get that password cracking stuff......

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: ascii in order

    To go 'up' a character, you need to convert the character to its ASCII equivalent (using the Asc function), add 1 to this number, then convert that number to the character equivalent to that ASCII code (using the Chr function).

    Assuming this is only for one character, the following will work:
    VB Code:
    1. Dim iInitialAsciiCode as Integer
    2. Dim iNextAsciiCode as Integer
    3.   iInitialAsciiCode = Asc(Text1.Text)
    4.   iNextAsciiCode = iInitialAsciiCode + 1
    5.   Text1.Text = Chr(iNextAsciiCode)
    ..which can also be written as:
    VB Code:
    1. Text1.Text = Chr(Asc(Text1.Text) + 1)

    Note tho that this will get errors if you try to go past the ASCII value of 255, and will also go through all characters, not just the ones normally used - to do that you will first need to find out which codes are normally used, for that you will need to find an ASCII character table.

  5. #5
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: ascii in order

    A=65, Z=90
    a=97, z=122

  6. #6
    Lively Member
    Join Date
    Jan 2008
    Posts
    114

    Re: ascii in order

    I do believe these are correct.

    Key Codes
    Constant Value Description
    vbKeyLButton 1 Left mouse button
    vbKeyRButton 2 Right mouse button
    vbKeyCancel 3 CANCEL key
    vbKeyMButton 4 Middle mouse button
    vbKeyBack 8 BACKSPACE key
    vbKeyTab 9 TAB key
    vbKeyClear 12 CLEAR key
    vbKeyReturn 13 ENTER key
    vbKeyShift 16 SHIFT key
    vbKeyControl 17 CTRL key
    vbKeyMenu 18 MENU key
    vbKeyPause 19 PAUSE key
    vbKeyCapital 20 CAPS LOCK key
    vbKeyEscape 27 ESC key
    vbKeySpace 32 SPACEBAR key
    vbKeyPageUp 33 PAGE UP key
    vbKeyPageDown 34 PAGE DOWN key
    vbKeyEnd 35 END key
    vbKeyHome 36 HOME key
    vbKeyLeft 37 LEFT ARROW key
    vbKeyUp 38 UP ARROW key
    vbKeyRight 39 RIGHT ARROW key
    vbKeyDown 40 DOWN ARROW key
    vbKeySelect 41 SELECT key
    vbKeyPrint 42 PRINT SCREEN key
    vbKeyExecute 43 EXECUTE key
    vbKeySnapshot 44 SNAPSHOT key
    vbKeyInsert 45 INS key
    vbKeyDelete 46 DEL key
    vbKeyHelp 47 HELP key
    vbKeyNumlock 144 NUM LOCK key

    KeyA Through KeyZ Are the Same as Their ASCII Equivalents: 'A' Through 'Z'
    Constant Value Description
    vbKeyA 65 A key
    vbKeyB 66 B key
    vbKeyC 67 C key
    vbKeyD 68 D key
    vbKeyE 69 E key
    vbKeyF 70 F key
    vbKeyG 71 G key
    vbKeyH 72 H key
    vbKeyI 73 I key
    vbKeyJ 74 J key
    vbKeyK 75 K key
    vbKeyL 76 L key
    vbKeyM 77 M key
    vbKeyN 78 N key
    vbKeyO 79 O key
    vbKeyP 80 P key
    vbKeyQ 81 Q key
    vbKeyR 82 R key
    vbKeyS 83 S key
    vbKeyT 84 T key
    vbKeyU 85 U key
    vbKeyV 86 V key
    vbKeyW 87 W key
    vbKeyX 88 X key
    vbKeyY 89 Y key
    vbKeyZ 90 Z key

    Key0 Through Key9 Are the Same as Their ASCII Equivalents: '0' Through '9
    Constant Value Description
    vbKey0 48 0 key
    vbKey1 49 1 key
    vbKey2 50 2 key
    vbKey3 51 3 key
    vbKey4 52 4 key
    vbKey5 53 5 key
    vbKey6 54 6 key
    vbKey7 55 7 key
    vbKey8 56 8 key
    vbKey9 57 9 key

    Keys on the Numeric Keypad
    Constant Value Description
    vbKeyNumpad0 96 0 key
    vbKeyNumpad1 97 1 key
    vbKeyNumpad2 98 2 key
    vbKeyNumpad3 99 3 key
    vbKeyNumpad4 100 4 key
    vbKeyNumpad5 101 5 key
    vbKeyNumpad6 102 6 key
    vbKeyNumpad7 103 7 key
    vbKeyNumpad8 104 8 key
    vbKeyNumpad9 105 9 key
    vbKeyMultiply 106 MULTIPLICATION SIGN (*) key
    vbKeyAdd 107 PLUS SIGN (+) key
    vbKeySeparator 108 ENTER (keypad) key
    vbKeySubtract 109 MINUS SIGN (-) key
    vbKeyDecimal 110 DECIMAL POINT(.) key
    vbKeyDivide 111 DIVISION SIGN (/) key

    Function Keys
    Constant Value Description
    vbKeyF1 112 F1 key
    vbKeyF2 113 F2 key
    vbKeyF3 114 F3 key
    vbKeyF4 115 F4 key
    vbKeyF5 116 F5 key
    vbKeyF6 117 F6 key
    vbKeyF7 118 F7 key
    vbKeyF8 119 F8 key
    vbKeyF9 120 F9 key
    vbKeyF10 121 F10 key
    vbKeyF11 122 F11 key
    vbKeyF12 123 F12 key
    vbKeyF13 124 F13 key
    vbKeyF14 125 F14 key
    vbKeyF15 126 F15 key
    vbKeyF16 127 F16 key
    "What is a hackers worst nightmare you may ask? Vista! Not that its hard to bypass its just that it gives you stupid annoying errors!"


  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: ascii in order

    No, those are KeyCodes rather than ASCII codes - there are differences.

    Also, this thread is over 3 years old, so I really hope the OP isn't still trying to sort it out - and that they (and the other people who subscribed to this thread) aren't too annoyed at getting notification of your post.

  8. #8
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: ascii in order

    Quote Originally Posted by [email protected]
    sigh yet another dead end of searching....I can't even begin to start this one, I am stumped....SO I came here...

    what I am looking for is....

    a code that will change the letter in a text box +1 (including A - Z 'upper and lower case' ,numbers/charaters ) pretty much anything that is "normally used for typing" I want it to go off in order.

    after it gets to the last one in the order it goes back to the first keeps it in the first spot and does the same loop with the seccond spot, then changes the first one to the seccond in the loop, etc....

    example:
    A
    B
    .(skip ahead)
    .(skip ahead)
    Z
    AA
    AB
    .(skip ahead)
    .(skip ahead)
    BA
    BB

    if you don't get that then I can explain it better.

    I only need the basic code and idea of how to do it, not the entire thing, I know it will be long...maybe lol.
    The most usual characters that are used in typing start from 32 to 255. So you need to loop from there.

    Something like this:
    vb.net Code:
    1. For i = 32 to 255
    2.     Print Chr(i)
    3.     For j = 32 to 255
    4.         Print Chr(i)  & Chr(j)
    5.         For k = 32 to 255
    6.             Print Chr(i)  & Chr(j) & Chr(k)
    7.  
    8.                 '... More FORs follow here...
    9.  
    10.                      Print Chr(i)  & Chr(j) & Chr(k) & ....
    11.  
    12.                 '....
    13.        Next
    14.     Next
    15. Next
    This is not so practical to put 255 or so loops there. So what we do is create one function and call it over and over again from within itself (recursion).

    vb.net Code:
    1. Private codesList As List(Of String)      'To hold our generated values
    2.  
    3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4.         'All codes it too time consuming. We take only A to E for example here
    5.         GenerateCodes("A", "E")    
    6.     End Sub
    7.  
    8.     Private Sub GenerateCodes(ByVal startChar As Char, ByVal endChar As Char)
    9.         'initialize and empty list where we will store the codes
    10.         codesList = New List(Of String)
    11.         'Get the codes
    12.         GetCodes("", Asc(startChar), Asc(endChar))
    13.         'Now we have all the codes we want. So let's display it in our debug window
    14.         For Each s As String In codesList
    15.             Debug.Print(s)
    16.         Next
    17.     End Sub
    18.  
    19.     'Recursive function
    20.     Private Sub GetCodes(ByVal code As String, ByVal startIndex As Integer, ByVal endIndex As Integer)
    21.         For i As Integer = startIndex To endIndex
    22.             Dim newCode As String = code & Chr(i)
    23.             codesList.Add(newCode)
    24.             GetCodes(newCode, startIndex, i - 1)
    25.             GetCodes(newCode, i + 1, endIndex)
    26.         Next
    27.     End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  9. #9
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: ascii in order

    Quote Originally Posted by si_the_geek
    No, those are KeyCodes rather than ASCII codes - there are differences.

    Also, this thread is over 3 years old, so I really hope the OP isn't still trying to sort it out - and that they (and the other people who subscribed to this thread) aren't too annoyed at getting notification of your post.
    Ohhhh...

    Didn't notice this.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  10. #10
    Fanatic Member technorobbo's Avatar
    Join Date
    Dec 2008
    Location
    Chicago
    Posts
    864

    Re: ascii in order

    1 form 1 textbox
    Code:
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Private Sub Form_Load()
    Dim i As Long, x As Long, y As Long
    Me.Show
    For i = 0 To 2147483647
        x = i
        Text1 = ""
        Do
            y = x Mod 27
            If y = 0 Then y = 1
            Text1 = Chr(y + 64) & Text1
            x = Int(x / 27)
        Loop While x > 0
        Me.Refresh
        DoEvents
        Sleep 100
    Next
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
    End
    End Sub
    I put a delay in it so you can examine the progress.
    Have Fun,

    TR
    _____________________________
    Check out my Alpha DogFighter2D Game Demo and Source code. Direct Download:http://home.comcast.net/~technorobbo/Alpha.zip or Read about it in the forum:http://www.vbforums.com/showthread.php?t=551700. Now in 3D!!! http://home.comcast.net/~technorobbo/AlPha3D.zip or read about it in the forum: http://www.vbforums.com/showthread.php?goto=newpost&t=552560 and IChessChat3D internet chess game

  11. #11
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: ascii in order

    Need Ascii table : check the link in my signature
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  12. #12
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: ascii in order

    @Pradeep, this is VB6 forum, not VB.Net. Your code should not post here.

    I think the OP wants to have a listing of strings in order like column-headers in Excel.

    In code below, change 65, 89 and 90 for a wider range if required.
    A different approach need to be used for a non-contigurous character range.
    Code:
    Option Explicit
    
    Function NextStr(Str1 As String) As String
       Dim a As Byte, n As Long
       
       n = Len(Str1)
       If n Then
          a = Asc(Right$(Str1, 1))
          Select Case a
             Case 65 To 89  '-- "A" to "Y"
                NextStr = Left$(Str1, n - 1) & Chr$(a + 1)
             Case 90        '-- "Z"
                NextStr = NextStr(Left$(Str1, n - 1)) & "A" '-- recursive call
             Case Else
                MsgBox "Invalid character in input string: " & Str1
          End Select
       Else
          NextStr = "A"
       End If
    End Function
    
    Sub GenerateStr()
       Dim i As Long, Str1 As String
       
       For i = 1 To 1000
          Str1 = NextStr(Str1)
          Debug.Print Str1; "  ";
          If i Mod 20 = 0 Then Debug.Print '-- break line
       Next
    End Sub
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  13. #13
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: ascii in order

    I think that's enough now folks - the OP has not replied for over 3 years, so I would be amazed if your replies are helping them at all.

    As my warning didn't stop total necromancy, I'm closing the thread.

Posting Permissions

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



Click Here to Expand Forum to Full Width