Combobox, asking again

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Combobox, asking again

Elaine LaBorde
I've asked before and got no responses that I am aware of, so I'll try, try
again.

I know that this should be so easy and I feel foolish because I can't
seem to make it work. All I want to do here is to load a list into a
combobox list and be able to change the items in it. In other words,
select an item in the list, make changes in the text box part of the
combo box and click "OK" to have that change updated in the list part
of the combobox. Then click "Done" when I'm finished. I know that's
not hard. I know it's a snap. But for some reason it's escaping me.
Can you all help? Here's the code so far:

Option Explicit
   Const EMPTY_ITEM=vbNullChar      'Big fat nothing
   Const NOWHERE As Integer=-1      'Initial location pointer in List
   Public strVarLabel As String
   Public strVarLabelList() As String
   Public lngNumOfVars As Long
   Public intIndex As Integer

Sub Main
   Dim objSpssInfo As ISpssInfo
   Set objSpssInfo = objSpssApp.SpssInfo
   lngNumOfVars = objSpssInfo.NumVariables - 1
   ReDim strVarLabelList(lngNumOfVars)
   With objSpssInfo                    'Load Variable Label list
      For intIndex = 0 To lngNumOfVars
         strVarLabel = .VariableLabelAt(intIndex)
         strVarLabelList(intIndex) = strVarLabel
      Next intIndex
   End With
   Begin Dialog UserDialog 610,329,"VAR Label Editor",.EditVarLabels
      Text 120,14,340,14,"Edit Labels as desired.  Click ""Done"" when
finished."
      ComboBox 70,35,470,203,strVarLabelList(),.EditLabel
      OKButton 110,259,90,21
      PushButton 260,259,90,21,"Done"
      CancelButton 410,259,90,21
   End Dialog
   Dim dlg As UserDialog
   Dialog dlg
End Sub

Private Function EditVarLabels(DlgItem As String, Action As Integer,
SuppValue As Long) As Boolean
   Dim lngNItem As Long
   DlgValue "EditLabel",lngNItem
   Select Case Action
      Case 1 'Dialog box initialization
         lngNItem=NOWHERE
         intIndex=NOWHERE
         strVarLabel=EMPTY_ITEM
         DlgValue "EditLabel",lngNItem
         DlgEnable "Done",False
      Case 2 'Value changing or button pressed
         Select Case DlgItem
            Case "EditLabel" 'Item selected in combobox list
               lngNItem=DlgValue("EditLabel")
               intIndex=lngNItem
               If (intIndex<UBound(strVarLabelList) And (intIndex>NOWHERE))
Then
                  strVarLabel=strVarLabelList(intIndex)
               End If
               EditVarLabels = True 'do not exit the dialog
               Case "OK" 'OK button clicked
                  DlgEnable "Done",True
                  'strVarLabelList(intIndex)=strVarLabel
               Case "Done" 'Done button clicked
                  EditVarLabels = True 'do not exit the dialog
               Case "Cancel" 'Cancel button clicked
                  Exit All
                  'EditVarLabels = False 'exit the dialog
               End Select
       Case 3 'ComboBox text changed
          Select Case DlgItem
             Case "EditLabel" 'Label changed
                strVarLabel=DlgText(DlgItem)
             End Select
             EditVarLabels = True 'do not exit the dialog
       Case 4 'Focus changed
          'EditVarLabels = True 'do not exit the dialog
       Case 5 'Idle
          'Wait 2.0
       Case 6 'Function key
       End Select
End Function

Where am I going so terribly wrong? Thank you very, very much for your
help.

Elaine

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD