teamdad Posted December 31, 2003 Posted December 31, 2003 I have the following code below for a small project I am working on and I need help to modify it. As it is; the code will produce an output that looks like this: Who: When: Why: I would like to have it use something like an if / then statement that would produce the output for the textbox only if there is something typed in the textbox and would skip over it if nothing was typed in the textbox. For example if only Who and Why had something typed in them. The output would look like this. Who: Joe Woods Why: Called in sick *********My existing code********* Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Label1.Text = "WHO" Label2.Text = "WHEN" Label3.Text = "WHY" TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" TextBox4.Multiline = True Button1.Text = "GO" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strOutput As String strOutput = "Who:" & vbTab & TextBox1.Text & vbCrLf strOutput &= "When:" & vbTab & TextBox2.Text & vbCrLf strOutput &= "Why:" & vbTab & TextBox3.Text & vbCrLf strOutput &= "Test:" & vbTab & ComboBox1.Text & vbCrLf TextBox4.Text = strOutput End Sub ******************************** I was also wondering if it would be possible to have another button in the form that would somehow place the text from TextBox4 with it's orignal formatting to whatever other program the windows curser is in. ( like passing the text from this program to another program like Notepad ) If this isn't possible would I be able to copy the text from TextBox4 to the Windows Clipboard so I can then paste it into another program using Ctrl-V ( the standard paste method in Windows with the keyboard. ) Any help on this would be more than greatly appreciated. Thanks Quote
FartNocker Posted December 31, 2003 Posted December 31, 2003 Haven't tried it but it will gove you ideas. It should work Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strOutput As String Dim Box1 As String = TextBox1.Text Dim Box2 As String = TextBox1.Text Dim Box3 As String = TextBox1.Text If Box1 <> "" Then strOutput = "Who:" & vbTab & Box1 & vbCrLf If Box2 <> "" Then strOutput &= "When:" & vbTab & Box2 & vbCrLf If Box3 <> "" Then strOutput &= "Why:" & vbTab & Box3 & vbCrLf strOutput &= "Test:" & vbTab & ComboBox1.Text TextBox4.Text = strOutput End Sub I don't think you need the "& vbCrLf" at the end of the comboBox1.text so I left it off. But then again, I don't know what you are trying to do. Mark Quote
AndreRyan Posted January 1, 2004 Posted January 1, 2004 Don't use vbCrLf, use Environment.NewLine. To copy text onto the clipboard use:System.Windows.Forms.Clipboard.SetDataObject(Textbox4.Text) Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.