I need to collect descriptions of a variable number of IP addresses stored
in a 2 column array.  The first column has the address and the second needs
to have a user entered description.

The form I am using has a listbox displaying the columns of the array.  I
want the user to be able to enter descriptions row by row as selected by
clicking on one row at a time in the listbox.

Joe,

Take a look at the code below. It will run as is.

You don't have to create all the classes in a prg file like I have done for your own project but it illustrates how to use the ListItemID of a listbox to control where input from a textbox is placed in the array.

Ken Dibble
www.stic-cil.org

*** BEGIN CODE ***
PUBLIC oForm

oForm = CREATEOBJECT("MyForm")

oForm.Show()

DEFINE CLASS MyForm AS Form
     ChosenItemID = 0

     PROCEDURE INIT
          THIS.AddObject("MyList","MyListBox")

          THIS.MyList.Visible = .T.

          THIS.AddObject("IPDesc","TextBox")

          WITH THIS.IPDesc
               .Left = 220
               .Top = 40
               .Width = 100
               .Height = 22
               .Visible = .T.
          ENDWITH

          THIS.AddObject("EnterButton","MyButton")

          WITH THIS.EnterButton
               .Left = 220
               .Top = 80
               .Visible = .T.
          ENDWITH
     ENDPROC

     PROCEDURE EnterData
IF (NOT EMPTY(THISFORM.ChosenItemID)) AND (NOT EMPTY(THISFORM.IPDesc.Value)) THISFORM.MyList.aContents(THISFORM.ChosenItemID,2) = ALLTRIM(THISFORM.IPDesc.Value)

               THISFORM.MyList.Requery()

               THISFORM.IPDesc.Value = ""

               THISFORM.ChosenItemID = 0
          ELSE
               MESSAGEBOX("Nothing to enter or no place to put it.")
          ENDIF
     ENDPROC
ENDDEFINE

DEFINE CLASS MyListBox AS ListBox
     Width = 200
     Height = 200
     ColumnCount = 2
     DIMENSION aContents(5,2)

     PROCEDURE INIT
          THIS.aContents(1,1) = "192.44.01.01"
          THIS.aContents(1,2) = ""
          THIS.aContents(2,1) = "193.44.01.01"
          THIS.aContents(2,2) = ""
          THIS.aContents(3,1) = "192.45.01.01"
          THIS.aContents(3,2) = ""
          THIS.aContents(4,1) = "192.44.03.01"
          THIS.aContents(4,2) = ""
          THIS.aContents(5,1) = "192.44.01.07"
          THIS.aContents(5,2) = ""

          THIS.RowSourceType = 5
          THIS.RowSource = "THIS.aContents"

          THIS.Requery()
    ENDPROC

    PROCEDURE Click
          IF NOT EMPTY(THIS.aContents(THIS.ListItemID,1))
               THISFORM.EnterButton.Enabled = .T.

               THISFORM.ChosenItemID = THIS.ListItemId
          ELSE
               THISFORM.EnterButton.Enabled = .F.

               THISFORM.ChosenItemID = 0
          ENDIF
    ENDPROC
ENDDEFINE

DEFINE CLASS MyButton AS CommandButton
     Width = 70
     Height = 20
     Caption = "ENTER"
     Enabled = .F.

     PROCEDURE Click
          THISFORM.EnterData()
     ENDPROC
ENDDEFINE
*** END CODE ***

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to