Results 1 to 6 of 6

Thread: Printing the Ascii code of a string into a text box.

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004
    Posts
    12

    Printing the Ascii code of a string into a text box.

    Hi all,

    I need a code that will do as the title suggests, take a string, letter by letter, and print out the ascii code to a text box of each letter. I have not used Visual Basic for quite some time, and remember learning how to do this, but forgot how.

    Thanks in advance.
    Chris

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Printing the Ascii code of a string into a text box.

    Add text1 and txtout and a command button:

    VB Code:
    1. Option Explicit
    2. Dim x As Integer
    3. Dim z As Integer
    4.  
    5. Private Sub Command1_Click()
    6.   x = Len(Text1.Text)
    7.   For z = 1 To x
    8.     txtout.Text = txtout.Text & Asc(Mid(Text1.Text, z, 1)) & " "
    9.   Next z
    10. End Sub
    11.  
    12. Private Sub Form_Load()
    13.   Text1.Text = ""
    14.   txtout.Text = ""
    15. End Sub
    Attached Images Attached Images  

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Printing the Ascii code of a string into a text box.

    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Command1_Click()
    4.     Dim i As Integer
    5.     If Text1.Text = vbNullString Then Exit Sub
    6.     For i = 1 To Len(Text1.Text)
    7.         Text2.Text = Text2.Text & Asc(Mid$(Text1.Text, i, 1)) & ";"
    8.     Next
    9. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Printing the Ascii code of a string into a text box.

    I almost decided to use dynamic textboxes for the answers, but changed my mind. I must have worked for a good 5 minutes. Hope you enjoy it

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Printing the Ascii code of a string into a text box.

    To the minute!
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Printing the Ascii code of a string into a text box.

    Twice in the same day!

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