locked
Array with text boxes RRS feed

  • Question

  • I have a series of text boxes in the graphics window (actually have 10 but only show 2 here), I would like to create an array to check each text box to see if they are empty.

    where I have the most trouble is naming the 10 text boxes in the array.

    Also can an array be written to create 10 text boxes? 

      LocTextbox1 = Controls.AddTextBox (117,77)
      Controls.SetSize (LocTextbox1, 210,22)
      Controls.SetTextBoxText(LocTextbox1, "")
      Controls.TextTyped = LocTextBox1_textchange

    LocTextbox2 = Controls.AddTextBox (117,102)
    Controls.SetSize (LocTextbox2, 210,22)
    Controls.SetTextBoxText(LocTextbox2, "")
    Controls.TextTyped = LocTextBox2_textchange

    Sub LocTextBox1_textchange
      Itemlocation1 = Controls.GetTextBoxText (LocTextbox1  )
    EndSub

    Sub LocTextBox2_textchange
      Itemlocation2 = Controls.GetTextBoxText (LocTextbox2  )
    EndSub

     

    any help is greatly appreciated.

    Monday, July 18, 2011 5:56 PM

Answers

  • Yes any variable, shape or textbox etc can be an element in an array, just use the square brackets [].

    Simple multi-box example:

    numTextBox = 6
    For i = 1 To numTextBox
      textBox[i] = Controls.AddTextBox(50,50*i)
    EndFor
    Controls.TextTyped = OnTextTyped

    Sub OnTextTyped
      lastTextBox = Controls.LastTypedTextBox
      For i = 1 To numTextBox
        If (lastTextBox = textBox[i]) Then
          GraphicsWindow.ShowMessage("TextBox "+i+" used", "Information")
        EndIf
      EndFor
    EndSub


    • Marked as answer by SFC-P33A Monday, July 18, 2011 6:44 PM
    Monday, July 18, 2011 6:14 PM

All replies

  • Yes any variable, shape or textbox etc can be an element in an array, just use the square brackets [].

    Simple multi-box example:

    numTextBox = 6
    For i = 1 To numTextBox
      textBox[i] = Controls.AddTextBox(50,50*i)
    EndFor
    Controls.TextTyped = OnTextTyped

    Sub OnTextTyped
      lastTextBox = Controls.LastTypedTextBox
      For i = 1 To numTextBox
        If (lastTextBox = textBox[i]) Then
          GraphicsWindow.ShowMessage("TextBox "+i+" used", "Information")
        EndIf
      EndFor
    EndSub


    • Marked as answer by SFC-P33A Monday, July 18, 2011 6:44 PM
    Monday, July 18, 2011 6:14 PM
  • Thank you litdev, that is what I was trying to do, funny how easy it was, it was taking me hours
    Monday, July 18, 2011 6:45 PM