locked
Can I Input Text by Pasting it From the Clipboard? RRS feed

  • Question

  • Hello everyone.

    I'm a programming novice, and have just written a very rudimentary program using QBASIC.  Quite simply, the program lets the user input certain types of text, creates a .txt file on my C drive, and stores the inputted text in that file.

    Example:

    First Name:  Jay
    Last Name:  Danniel
    Address:  123 Sample Street
    State:  Vermont
    Zip:  12345

    I would like to try revising this program with Small Basic.  I've installed SB and glanced quickly through the Introducing Small Basic PDF file.  Right now, I have two questions.

    1.  One of the problems with the QBASIC program is that I cannot input text by pasting it from the Clipboard.  Will Small Basic allow me to do that?  Let's say, for example, I want to paste 123 SAMPLE STREET from the Clipboard, when I input the ADDRESS data.  Can that be done with Small Basic?

    2.  I didn't find anything in the PDF file that explains how to write to a file.  Granted, I admit I haven't read the PDF file thoroughly, yet, but I did search the file via various keywords, and didn't see anything pertaining to opening a file and writing to it.

    Does Small Basic have a command similar to this:

    open "test.txt" for output as #1

    I'm assuming it does.  What keyword(s) should I search for in the PDF file?  Or, is there documentation on-line that explains this?  Can you provide me with a link, please?

     

    Thank you for any assistance you care to give.  J. Danniel

     

     

     

    Thursday, May 26, 2011 8:50 PM

Answers

  • 1] Text can be pasted into a textbox from the Controls method

    2] There are a number of ways to write and read to Text files using the File method.

    The following code (save it somewhere first) will append the textbox text to the file 'sample.txt' in the same directory as the saved SmallBasic file.

    textbox1 = Controls.AddTextBox(50,50)
    button1 = Controls.AddButton("Hit Me",250,50)
    Controls.ButtonClicked = OnButtonClicked

    Sub OnButtonClicked
      If (Controls.LastClickedButton = button1) Then
        input = Controls.GetTextBoxText(textbox1)
        File.AppendContents(Program.Directory+"/sample.txt",input)
      EndIf
    EndSub

    • Proposed as answer by AirWaves Friday, May 27, 2011 7:17 AM
    • Marked as answer by litdev Tuesday, June 7, 2011 5:57 PM
    Thursday, May 26, 2011 9:15 PM