Results 1 to 6 of 6

Thread: Info in " "s into a string from Richtextbox.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83

    Info in " "s into a string from Richtextbox.

    This is a bit hard to explain so please bar with me. I have a richtext box where the user types in commands. When the user
    types in the command print "some text here" I need to be able to put the text in " " 's into a string. For the life of me I cant find a way to do this. Even if your not sure please post. Any idea's are welcome.
    12/32/84 - I need some code to make me a sandwhich.

  2. #2
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    A quick and dirty way would be to use the string.split function.
    You pass in a character to split at, in this case an ", then you get an array of strings back.
    You can then go through the array and look for the word print in the elements. If the print word is in index 10, that would mean you need to print out index 11.

    Or another way that will require a little more coding, but not much, would be to use the instring function and the substring functions. First you would look for the word 'print' in the string with the instr function. When if finds it, it will return an index of where that string is. You add 6 or 7 to that number, and you should be at the start of the string to print. Now you would need to start looking from there with the instr function to find the next quote. That would be the ending point of the string you need to print. You figure out the length by subtracting the start from the end. Now, you use the substring function and pass in where to start, and the length, and you will get the string you need to print.

    Hope that helps. If you need me to, when I have the time I can go ahead and write out the code for you.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    I would really appreciate it if you could write out a code example for me. I understand what your saying but without seeing an example I'm lost.

    Thanks for your time.
    12/32/84 - I need some code to make me a sandwhich.

  4. #4

    some code

    idk if this is EXACTLY what your lookin for but... i'll try my best

    have two textboxes and a button

    under the button...
    **This does not use quotes!**
    dim startwrite as integer
    if lcase(mid(textbox1.text, 1, 5)) = "print" then
    startwrite = startwrite + 7
    textbox2.text = mid(textbox1.text, startwrite)
    end if

    hope this helps... im trying to do the same thing! well i think...

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Colorado
    Posts
    83
    Yeah we're doing the same thing. Well kinda of. Im trying to recreate an old language for windows.

    Thanks for the code!
    12/32/84 - I need some code to make me a sandwhich.

  6. #6

    Talking a little more code

    i'm not sure if this will work... but it seems a little better than my last code, and it works with quotes

    same thing... two textboxes and a button
    under the button again:

    Dim StartWrite as Integer
    If LCase(Mid(TextBox1.Text, 1, 5)) = "print" Then
    StartWrite = StartWrite + 8
    TextBox2.Text = Mid(TextBox1.Text, StartWrite)
    Do Until Mid(TextBox1.Text, StartWrite) = "";"
    Loop
    End If

    hope this works a little bit better than the last code, if at all...

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