Hack Forums
[.NET] What would this code be? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] What would this code be? (/showthread.php?tid=488234)



What would this code be? - Xawn - Jun 18, 2010

I'm making a bio creating application, and I need some help.
Could you please tell me the code I need for this situation.

I have Textbox1.
I also have Button1.

I want to make it so that by clicking Button1, I copy (to my clipboard) the text in Textbox1.

Help would be appreciated.


* - SIM-263922 - Jun 18, 2010

Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    TextBox1.SelectAll()
    TextBox1.Copy()
End Sub

This should work, I tested it.


* - ๖ۣۜBlueAce™ - Jun 18, 2010

Code
My.Computer.Clipboard.SetText(Textbox1.Text)



* - Xawn - Jun 18, 2010

(Jun 18, 2010 04:06 AM)yourkii Wrote:  
Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    TextBox1.SelectAll()
    TextBox1.Copy()
End Sub

This should work, I tested it.

Thank you very much. +rep.


* - ๖ۣۜBlueAce™ - Jun 18, 2010

(Jun 18, 2010 04:14 AM)sB Legend Wrote:  Thank you very much. +rep.

LMAO.. saying +rep does NOT add rep .. 🤣🤣🤣

u need to be L33T/UB3R for sharing rep 😉


* - Mario - Jun 18, 2010

(Jun 18, 2010 04:15 AM)BlueAce_Pragy Wrote:  LMAO.. saying +rep does NOT add rep .. 🤣🤣🤣

u need to be L33T/UB3R for sharing rep 😉

lmao well we all started some where didnt we :)


* - Xawn - Jun 18, 2010

(Jun 18, 2010 04:15 AM)BlueAce_Pragy Wrote:  LMAO.. saying +rep does NOT add rep .. 🤣🤣🤣

u need to be L33T/UB3R for sharing rep 😉
I'm not stupid bro.

I am used to Se7en Sins, so I said that, to find there's a Thanks button instead.

ON TOPIC:

Alright.
If this copies one single text box:
Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  TextBox1.SelectAll()
  TextBox1.Copy()

How could I make it copy two Textboxes, by clicking one button?


* - Breakbeat Junkie - Jun 18, 2010

(Jun 18, 2010 04:23 AM)sB Legend Wrote:  I'm not stupid bro.

I am used to Se7en Sins, so I said that, to find there's a Thanks button instead.

ON TOPIC:

Alright.
If this copies one single text box:
Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  TextBox1.SelectAll()
  TextBox1.Copy()

How could I make it copy two Textboxes, by clicking one button?

Code
My.Computer.Clipboard.SetText(Textbox1.Text & Textbox2.Text)

Or

Code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  TextBox1.SelectAll()
  TextBox1.Copy()
  TextBox2.SelectAll()
  TextBox2.Copy()

Don't know if this works tho



* - Xawn - Jun 18, 2010

Cheers bro, first one works fine, second one overwrites the previous text.