Problem with a simple exercice about invest words RRS feed

  • Question

  • hi! im new in SB, and im trying to teach the code, so, i need to write a program with controls that ask a text on a capture text box and in another capture text box transfered in the invest way, for example: "write something" firt box: friend, second box: dneirf. I have bout capture box, but i can´t found the right code to do that, i think that can be apend, but i don´t really sure.
    Monday, January 14, 2013 3:03 AM


  • Hello mangels18!

    To do what you want you need to know the category Controls, plus how to deal w/ event triggered subroutines.

    Basically you want 2 TextBoxes, so you need:

    tBox1 = Controls.AddTextBox(100,100) & tBox2 = Controls.AddTextBox(300,100)

    A result MultiTextBox:

    mBox  = Controls.AddMultiLineTextBox(175,200)

    Plus you need a "confirm" OK button:

    Controls.AddButton("OK"   265,150)

    Now we gotta set the event subroutine to be called every time a button on screen is clicked:

    Controls.ButtonClicked = CheckButton

    Here's the whole code:

    GraphicsWindow.BackgroundColor = "Yellow"
    GraphicsWindow.BrushColor = "Blue"
    tBox1 = Controls.AddTextBox(100,100)
    tBox2 = Controls.AddTextBox(300,100)

    GraphicsWindow.BrushColor = "Black"
    mBox  = Controls.AddMultiLineTextBox(175,200)

    GraphicsWindow.BrushColor = "Red"
    Controls.AddButton("OK"   265,150)

    Controls.ButtonClicked = CheckButton

    Sub CheckButton
      btn = Controls.GetButtonCaption( Controls.LastClickedButton )
      If btn = "OK" Then
        phrase = Controls.GetTextBoxText(tBox1)
        phrase = Text.Append( phrase, Controls.GetTextBoxText(tBox2) )
        Controls.SetTextBoxText(tBox1, "")
        Controls.SetTextBoxText(tBox2, "")
        Controls.SetTextBoxText(mBox, phrase)

    Try to understand what the above example do.

    Any doubts, jsut ask. Cya!

    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Monday, January 14, 2013 7:42 AM