[QUES]Sending multiple textbox lines

Discussion in 'Programming General' started by Soul Undead, Dec 1, 2008.

[QUES]Sending multiple textbox lines
  1. Unread #1 - Dec 1, 2008 at 8:06 PM
  2. Soul Undead
    Referrals:
    0

    Soul Undead Guest

    [QUES]Sending multiple textbox lines

    Ok, so I am making an auto talker.
    I easily managed to get it to send one line from a textbox.
    My problem is, I want it to send from 3 text boxes.

    here is my code:

    timer1
    Code:
            SendKeys.Send(RichTextBox2.Text)
            SendKeys.Send("{enter}")
    Button that starts:
    Code:
    
            RichTextBox2.SaveFile("C:\logs.txt")
            Timer1.Interval = TextBox1.Text
            Timer1.Enabled = True
            ToolStripStatusLabel1.Text = "Started!"
            ToolStripProgressBar1.Value = "100"
            ToolStripProgressBar1.ToolTipText = "Displays if it is activated or not"
            
    
    Button that stops:
    Code:
    Timer1.Enabled = False
            ToolStripStatusLabel1.Text = "Stopped!"
            ToolStripProgressBar1.Value = "0"
    I have it set to richtextbox as the message, as it creates a log.
    But I would use either: Rich or regular textbox.

    If I were to add 2 more textboxes, how would I get them to send all of them, instead of just the first line?
     
  3. Unread #2 - Dec 4, 2008 at 7:34 PM
  4. Stuart
    Joined:
    May 5, 2005
    Posts:
    1,580
    Referrals:
    2
    Sythe Gold:
    10

    Stuart Guru
    Banned

    [QUES]Sending multiple textbox lines

    Code:
        Private Sub Send_Multiline(ByVal txt As String)
            Dim lines() As String = Split(txt, vbNewLine)
            For Each line As String In lines
                ' do stuff here
                MsgBox(line)
            Next
        End Sub
    
     
  5. Unread #3 - Dec 12, 2008 at 3:47 AM
  6. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    [QUES]Sending multiple textbox lines

    Using what programmers call "Magic Numbers" is not recommended. When programmers tend to use number codes that people may not understand, they first declare the number as a constant at the beginning of the code file with a relevant name. I would recommend creating a constant called "CHAR_ENTER" or something similar, with the value 13. You could then use the following code:

    Code:
    'Beginning of code file
    Public Const CHAR_ENTER As Integer = 13
    '...
    '...
    chr(CHAR_ENTER)
    Makes more sense, doesn't it?
     
  7. Unread #4 - Dec 16, 2008 at 9:47 PM
  8. Soul Undead
    Referrals:
    0

    Soul Undead Guest

    [QUES]Sending multiple textbox lines

    Actually, it just writes to it, so it can remember the last message sent. Although it comes out as

    Code:
    {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}
    \viewkind4\uc1\pard\f0\fs17\par
    }
    I sent something random while testing it.
     
< Visual Basic | VB question >

Users viewing this thread
1 guest


 
 
Adblock breaks this site