On Sep 26, 2006, at 6:13 PM, D P wrote:


Hi
I have worked out how to load editfields on window open from post here, the LR and others. It did bring up a question though.

I first created an EditField1 set to be 20x20 px then set index to 0 and visible = false.

  In event OPEN on form load this code:

    dim x, y, xx, yy as integer
  dim e(8,8) as EditField
  For y = 20 to 180 step 20
    For x = 20 to 180 step 20
      yy = (y/20)-1
      xx = (x/20)-1
      e(yy,xx) = new EditField1
      e(yy,xx).Left = x
      e(yy,xx).Top = y
      e(yy,xx).text = str(e(yy,xx).index)
      e(yy,xx).Visible = True
    Next x
  Next y

  It works nicely loading a 9x9 array with 1 through 81 in the fields.

I then placed an pushbutton on the window and two edit fields (xfield to read in column (x), yfield to read in row (y)). I wanted to hit the pushbutton and get a msgbox to open with the text of the editfield choosen shown.

    dim x ,y as integer
  x = floor(val(xfield.text))
  y = floor(val(yfield.text))

MsgBox "Value of cell: " + "(" + xfield.text + " , " + yfield.text + ") is : " + e(x,y).text

All good except that the compiler takes exception to my array of editfields e(x,y)

  They/it don't exist.

In Open the array e(8,8) is declared as a local variable, which means that its scope is limited to the Open event, which is long over by the time you push the button. You will want to declare e as a property of the window, and deleted the dim e(8,8) from the Open event. Doing that assures that e will stay in scope.

Best,

Jack
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to