Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Go Back  Xtreme Visual Basic Talk > > > Copy to clipboard all Labels and Textboxes with a button


Reply
 
Thread Tools Display Modes
  #1  
Old 07-17-2015, 04:48 AM
brybamo brybamo is offline
Newcomer
 
Join Date: Jul 2015
Posts: 14
Default Copy to clipboard all Labels and Textboxes with a button


Hello all,

This is my first time in the forums, first time with Visual Basic also =]

I have this two issues, i created this program for a ticketing system, the idea for this is to fill up the boxes with the information then once finished, to click in a button and copy the content of the fields to the clipboard.

My first question is: Is it possible to copy all the Labels and textboxes from the program to the clipboard all with one button? How can i do this.

Second: Im having some kind of an issue with concatenating strings. What i need to do is to be able to add the text fromTextBox9 and TextBox10 to RichTextBox1 more than once, with out remplacing the text previuosly entered in RichTextBox1 everytime i click the "Add" button.


This is the code i have so far:

Quote:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim texto As String
Dim texto2 As String
Dim textototal As String
texto = TextBox9.Text
texto2 = TextBox10.Text
textototal = ("Action: " & texto & vbCrLf & "Result: " & texto2 & "")
RichTextBox1.Text = textototal

TextBox9.Text = ""
TextBox10.Text = ""

thank you very much in advace for taking a look!
Attached Images
File Type: png 2015-07-17 04_46_26-GSD Ticket Notes - Sony.png (15.6 KB, 4 views)
Reply With Quote
  #2  
Old 07-17-2015, 09:23 AM
Gruff's Avatar
GruffCopy to clipboard all Labels and Textboxes with a button Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

In programming it is possible to set a variable to itself plus another variable.
Code:
Dim A as integer = 2
Dim B as integer = 3
A = A + B
' A will now hold the value 5.
' You can shorten this in VB.NET by using the Plus Equals (+=) operator.
A += B
' Same result 5.
You can do the same with strings but you would use the Concatinate Equals (&=) operator.
Code:
Dim Name as string = "Billy"
Dim LastName as string = "Kidd"

Name &= " " & LastName
' Name will now hold "Billy Kidd"
Use the Clipboard object to interface with the windows clipboard.
Code:
Clipboard.Clear
Clipboard.SetText("Some Text")
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #3  
Old 07-17-2015, 11:54 PM
brybamo brybamo is offline
Newcomer
 
Join Date: Jul 2015
Posts: 14
Default

Ive been trying to look for the best way to copy to clipboard.

I need to be able to click the "Copy to Clipboard" button and to copy the text in both Labels and Textboxes in the program (listed in the screenshot), so that when i go to paste the text, i would get something like this:

--------Contact info--------
Name: Jessica Alba
User ID: 6000598576
Phone: +98-352-5689
Email: Jesica.Alba@Hotmail.com
Location: San Francisco, CA

--------Issue--------
Description: Unable to login to Windows

Error message: Account locked



--------Troubleshooting steps--------

Action: Account unlocked in AD

Result: User was able to login using same password

Action: Closing ticket as resolved

Result: Ticket closed


Dispatch reason: N/A


Not sure if you can get an idea... =/
Reply With Quote
  #4  
Old 07-19-2015, 05:37 AM
brybamo brybamo is offline
Newcomer
 
Join Date: Jul 2015
Posts: 14
Default

Hi,

Found out how to do the copy thing, its kinda like a mess the way i did it, i know ther emight be an easier way to do it, but is working for me, just one issue...

When i hit the button to copy, the text entered in the RichTextBox1 is being copied without spaces and line jumps. For example:

If i type:

Quote:
Account was unlocked.

User was able to login using same password.

Closing ticket as resolved.
It will paste this:

Quote:
Account was unlocked.User was able to login using same password.Closing ticket as resolved.
How can i fix this?


this is the code im using:

Quote:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

Dim Name As String
Dim User As String
Dim Phone As String
Dim Email As String
Dim Location As String
Dim Description As String
Dim sintest As String
Dim steps As String
Dim Dispatch As String



Name = TextBox1.Text
User = TextBox2.Text
Phone = TextBox3.Text
Email = TextBox4.Text
Location = TextBox5.Text
Description = TextBox6.Text
sintest = TextBox7.Text
steps = TextBox8.Text
Dispatch = TextBox9.Text

Clipboard.Clear()
Clipboard.SetText("------ Contact Information ------" & vbCrLf & "Name: " & Name & vbCrLf & "User ID: " & User & vbCrLf & "Phone: " & Phone & vbCrLf & "Email: " & Email & vbCrLf & "Location: " & Location & vbCrLf & vbCrLf & "------ Issue ------" & vbCrLf & "Description: " & Description & vbCrLf & vbCrLf & "Error: " & sintest & vbCrLf & vbCrLf & "------ Troubleshooting Steps ------" & vbCrLf & steps & vbCrLf & vbCrLf & "Dispatch reason (if applicable): " & Dispatch & "")


End Sub
Reply With Quote
  #5  
Old 07-22-2015, 10:39 AM
passel's Avatar
passelCopy to clipboard all Labels and Textboxes with a button passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,024
Default

Interesting about the RichTextBox.
I guess one way is to join the lines yourself.
Code:
Dim s as String = String.Join(vbNewLine, RichTextBox1.Lines)
Clipboard.SetText(s)
To make things a little easier to read, you also might want to use a stringbuilder object to build up the string, then convert the results to a string to send to the clipboard.
Code:
    Dim sb As New System.Text.StringBuilder

    sb.AppendLine("------ Contact Information ------")
    sb.AppendLine("Name: " & Name)
    sb.AppendLine("User ID: " & User)
    sb.AppendLine("Phone: " & Phone)
    sb.AppendLine("Email: " & Email)
    sb.AppendLine("Location: " & Location)
    sb.AppendLine(vbCrLf)
    sb.AppendLine("------ Issue ------")
    sb.AppendLine("Description: " & Description)
    sb.AppendLine(vbCrLf)
    sb.AppendLine("Error: " & sintest)
    sb.AppendLine(vbCrLf)
    sb.AppendLine("------ Troubleshooting Steps ------")
    sb.AppendLine(steps)
    sb.AppendLine(vbCrLf)
    sb.Append("Dispatch reason (if applicable): " & Dispatch)

    Clipboard.SetText(sb.ToString)
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.

Last edited by passel; 07-22-2015 at 10:52 AM.
Reply With Quote
  #6  
Old 07-24-2015, 11:32 PM
brybamo brybamo is offline
Newcomer
 
Join Date: Jul 2015
Posts: 14
Default

Thaaaaaank you passel, it´s working....

Awesome, i was able to find a workaround also, i changed the RichTextBox to a simple TextBox with multiline enabled and now it is saving text with line jumps.

I was told that working with stringbuilder is a little more complex, but it looks simple enough..

Thank you again!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
 
Copy to clipboard all Labels and Textboxes with a button
Copy to clipboard all Labels and Textboxes with a button
 
-->