hexagon logo

Dropdown Menu for SN / Production Number / ... (Dropdown reads from Textfile)

Hi,

I finished this little script with the help of Henniger123 (Thanks again!)

How it works is quite simple:

It reads every line from the textfile (up to 100 lines) and puts them into a dropdown List.
It then shows the list for selection and transfers a variable called "DROP_SEL" containing the selected Value to PCDMIS

Feel free to modify / use as you please...



Option Explicit

Sub Main()
    Dim PCDDmisApp As Object
    Dim PCDDmisPart As Object
    Dim PCDDmisCommands As Object
    Dim PCDDmisCommand As Object
    Dim DROP_SEL As String
    Set PCDDmisApp = CreateObject("PCDLRN.Application")
    Set PCDDmisPart = PCDDmisApp.ActivePartProgram
    Set PCDDmisCommands = PCDDmisPart.Commands
    Dim Command As Object
    
    Dim vSNRList(100) As String
    Dim vSNRLine As String
    Dim vSNRCount As Integer
    Dim vButton As Integer
    Dim retval

  'Get list from file
    vSNRCount = 0
  'Change Filepath to your needs...
    Open "U:\xxxxxxxxxxxxxxxxxxxxxxxxx\list.txt" For Input As #1
    Do While Not EOF(1)
      Line Input #1, vSNRLine
      vSNRList(vSNRCount) = vSNRLine
      vSNRCount = vSNRCount + 1
    Loop
    Close #1

  'Dim Dialog
    Begin Dialog DialogName1 200,184, "Part Number Selection Dialog Box"
      Text 10, 10, 88, 22, "N auswählen:"
      DropListBox 42, 76, 108, 186, vSNRList(), .DropList1
      CancelButton 42, 108, 40, 12
      OKButton 90, 108, 40, 12
    End Dialog
    Dim Dlg1 As DialogName1
    
  'start Dialog
    Dlg1.DropList1 = vSNRList(0)
    vButton = Dialog(Dlg1)
    
    If vButton = 0 Then Exit Sub
    
    Set PCDDmisCommand = PCDDmisCommands.Add(ASSIGNMENT, True)
    PCDDmisCommand.Marked = True
    retVal = PCDDmisCommand.PutText("DROP_SEL", DEST_EXPR, 0)
    retVal = PCDDmisCommand.PutText(Chr(34) + vSNRList(Dlg1.DropList1) + Chr(34), SRC_EXPR, 0)
End Sub​