Results 1 to 11 of 11

Thread: SendKeys command in a TextBox?

Threaded View

  1. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2012
    Posts
    290

    Re: SendKeys and Reading Textbox file line by line

    I'll explain the concept more in detail.
    In the program I introduce integer numbers in a textbox and the program performs some calculations after pressing the enter key in the textbox.
    Well, sometimes I want to save the list of numbers I introduced and for that task I save the number list in a text *.txt file.
    The text file contains integer numbers, one number in each line.

    Example of the data in the text file:
    1
    45
    3
    43
    etc...

    At the moment, the thing I want to do is to load a text file containing those integer numbers.
    The first task to do is to read the text file line by line to get each time 1 integer number.
    Once the program has the number, the program "writes" in a TextBox the number and press the enter key (ascii chr 13) and looks for the next number in the text file until the end of that file.

    At the moment I use the code shown above:
    Code:
    Dim NameOfTheFile As String = OpenFileDialog1.FileName
    Dim TextLine As String
    
    If System.IO.File.Exists(NameOfTheFile) = True Then
    Dim ObjReader As New System.IO.StreamReader(NameOfTheFile)
    
    Do While ObjReader.Peek() <> -1
    TEXTBOX_NumeroSalido.Focus()
    TextLine = ObjReader.ReadLine() & vbNewLine
    LISTBOX_Consejo.Items.Add(TextLine)
    TEXTBOX_NumeroSalido.Text = TextLine
    SendKeys.Send("{ENTER}")
    Loop
    The problem is that the program only shows the last number in the text file into the DataGridView control, instead of showing all the values that the textfile contains.
    In the ListBox all values are shown, but not in the DataGridView control.
    I think something with the command "Send Keys" is the problem. But I don't know.
    Last edited by Jose_VB; May 3rd, 2013 at 08:17 AM.

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