Results 1 to 19 of 19

Thread: TextBox Alignment Help

  1. #1

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Arrow TextBox Alignment Help

    I need to get data in text boxes aligned...

    ----------
    ----------
    ----------
    -5--7--9--
    -5--7--9--
    -3--5--7--
    This is my input (for those who know guitars its tabs) It works fine until i try to put another input like this to the right of it.

    ----------
    ----------
    ----------
    -5--7--9--
    -5--7--9--
    -3--5--7------------
    ----------
    ----------
    -5--7--9--
    -5--7--9--
    -3--5--7--

    It ends up like this. Is there anyway to make it like this..

    ---------- ------------
    ---------- ------------
    ---------- ------------
    -5--7--9-- -3--3--5---
    -5--7--9-- -3--3--5---
    -3--5--7-- -1--1--3---

    ...or am i just screwed with my tab writing program.
    PLEASE HELP ME I DONT KNOW WHAT IM DOING.
    Nick

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

    Re: TextBox Alignment Help

    Welcome to the Forums.

    You can use some string functions like Replace, Mid$, Instr, etc.

    What code have you written to ewrite out the strings/tabs. Can you post it?
    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

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: TextBox Alignment Help

    I play guitar too so I know what you're talking about.

    What you have to do is replace a "-" with whatever number they're entering.

    I attached a small example. only takes a few lines of code
    Attached Files Attached Files

  4. #4

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    Well, since I'm not sure what I am doing with visual basic (I have just started to take a computer programming class this trimester) and my teacher teaches me nothing, I don't know what ewrite means. However, what I am doing is putting my input directly into the text box with the command button click.

    If a.Value = True Then
    txtWrite.Text = "---" & vbCrLf & "-2-" & vbCrLf & "-2-" & vbCrLf & "-2-" & vbCrLf & "-0-" & vbCrLf & "---"
    End If

    The Input looks like this in the text box
    ---
    -2-
    -2-
    -2-
    -0-
    ---
    Nick

  5. #5

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    DigiRev,

    What does this code do hahaha
    Nick

  6. #6
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: TextBox Alignment Help

    It just replaces a "-" with the number entered into the textbox...

    Did you run the code to see what it does?

  7. #7

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    right now i'm trying this code in my form. The form i zipped from you does nothing when i start it up. What do i dimension or declare KeyAscii as?
    Nick

  8. #8
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: TextBox Alignment Help

    The first thing you need to do in your project is, fill the textbox you're using with the empty tab: ie:

    ----------
    ----------
    ----------
    ----------
    ----------
    ----------

    Then, with your form open, double-click the textbox to bring up the code window. Make your textbox's KeyPress() sub look like this:

    VB Code:
    1. Private Sub txtTab_KeyPress(KeyAscii As Integer)
    2. Dim lonStart As Long, strText As String
    3.  
    4. lonStart = txtTab.SelStart
    5. strText = txtTab.Text
    6. Mid$(strText, lonStart + 1, 1) = Chr$(KeyAscii)
    7. txtTab.Text = strText
    8. txtTab.SelStart = lonStart + 1
    9. KeyAscii = 0
    10. End Sub

    Now when the person enters a number into your tab textbox, it will keep the tab lines formatted

  9. #9

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    Oh I see, the problem is that I'm trying to make a program that will make tabbing much easier. It takes alot of time and effort to type in the individual numbers for the chords and such. So what I am trying to do is make buttons where you can select chords, powerchords, bar chords, and all that good stuff and just put them into one text box. Then you can push another command button and it will apear in the top text box. My problem is trying to put two sets of chords or whatever in the top text box because it ends up looking like this.

    ---
    -2-
    -2-
    -2-
    -0-
    ------
    -2-
    -2-
    -2-
    -0-
    ---
    Nick

  10. #10
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: TextBox Alignment Help

    Ok, this example is a bit more complicated, so I'm not sure if you'll understand the code completely, but it does what you want
    Attached Files Attached Files

  11. #11

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    When I run it and try to add D Major it says "runtime error 9 subscript out of range"
    for Mid$(strLines(StringNumber - 1), StartPos, 1) = NoteValue
    Nick

  12. #12

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    Do you want me to send you what I have of the program so far so you can take a look at it?
    Nick

  13. #13
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: TextBox Alignment Help

    Did you change any of the code?

    Because it works fine for me with no errors...

    Yeah, send me your project, that would make it easier

  14. #14

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    Ok, it's very, very simple stuff because i'm a total vb newb how did you zipit onto here? Sorry all I can ask is for your patients, i know little about computers.
    Nick

  15. #15
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: TextBox Alignment Help

    Under the box that you type your message in there's a button called "Manage Attachments" click it, and a new window will pop up. Click the "Browse" button, select your zip file, and click "Upload". It will tell you when the upload is finished, then close the window and post your message...

    You will need Winzip to zip your project if you don't have it already...just zip the whole folder containing your project's files

    www.Winzip.com

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

    Re: TextBox Alignment Help

    You can download a free version of WinZip from here
    http://www.winzip.com/
    Ok, it's an evaluation copy, but it works.
    Open WinZip, by selecting all the files in your project, right click, and select WinZip -> Add to Zip file. Give it a name, and the files will be compressed into one Zip file.
    Reply to a message, type in some text, and scroll down to the Manage Attachments button. Click BROWSE, and double-click on the .zip file.
    Then click ATTACH.
    When you SUBMIT the reply, the file will be included in the post.

    I see now that it's a 21-day trial period. I think it just nags you after that time has elapsed. I have a registered version, so I'm not sure.

  17. #17

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    I'll just send the whole thing as a form. Hope it works
    Attached Files Attached Files
    Nick

  18. #18
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: TextBox Alignment Help

    Well, the way you are doing it makes it kinda hard. You should start out with an empty tab and just fill in the spaces as they add chords

    I gotta go now, but when I get off work tomorrow I'll try and help you sort this thing out..

  19. #19

    Thread Starter
    Lively Member nickTHEguitarist's Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    82

    Re: TextBox Alignment Help

    Ok, thanks for all your help. Have fun at work while I stay home on Spring Break

    Take it Easy, Keep it real
    Nick

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