CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2008
    Posts
    11

    [RESOLVED] copy and paste help

    I am working on a program from my work, its a layway calculator. The problem i am running into is that they need to enter the information in to a different program. My goal is to speed the process up. What I am trying to do is add a copy feature that gets the information in the proper format so that it can be pasted in to other program. When i send the text to the multi lined text box using vbcr for the return it does not go to a new line it just creates a box. Please help Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Pearl of the orient
    Posts
    304

    Re: copy and paste help

    Welcome to the forums!

    May we see some code on how you are doing it? And enclose them with [code] tags.

  3. #3
    Join Date
    Dec 2008
    Posts
    19

    Re: copy and paste help

    I'm not clear on exactly what you are trying to accomplish. If you are trying to combine text strings and display in a text box and copy to the clipboard then this code will work:
    Code:
     Dim NewText As String
     NewText = "This is line number one" & vbCrLf
     NewText = NewText + "This line number two"
     Text1.Text = NewText
     Clipboard.Clear
     Clipboard.SetText NewText
    Tom

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: copy and paste help

    Almost:


    Code:
    NewText = NewText + "This line number two"
    should be:

    Code:
    NewText = NewText & "This line number two"
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Dec 2008
    Posts
    19

    Re: copy and paste help

    LOL... you, of course, are correct dglienna. It should be an ampersand rather than the plus sign. However, the code still executes properly using the plus sign.

    One other important thing to note in regards to the original question is whether the TextBox Multiline property is set to True. If not, you'll see the vbCrLf as a character which may be the "box" to which you referred.

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: copy and paste help

    Not necessarily:

    Code:
    Dim NewText as Integer
    NewText = 3
    NewText = NewText + "This line number two"
    That wouldn't work
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Dec 2008
    Posts
    11

    Re: copy and paste help

    Thank you for your replies and I wish I had time to try that and post some of the code but I am really busy now. I will try that out and get back ASAP. Thanks again!!

  8. #8
    Join Date
    Dec 2008
    Posts
    19

    Re: copy and paste help

    Quote Originally Posted by dglienna View Post
    Not necessarily:

    Code:
    Dim NewText as Integer
    NewText = 3
    NewText = NewText + "This line number two"
    That wouldn't work
    Nor would the ampersand work with your code.

  9. #9
    Join Date
    Dec 2008
    Posts
    11

    Re: copy and paste help

    Thank very much Tom Moran and to the rest of you. I got it to work by adding the vbCrLf. I was using vbCr. Thank you again.

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

Featured