hexagon logo

VB code help

Hi Hi
Just dabbling with some VB and being a complete novice I need some helpSmiley

I tried the following code to insert three standard comments we use into programs, saves typing the same thing over and over again but it will only insert the comments at the end of the program and I need it to insert at the current cursor position.

What have I missed out?

Sub Main

Dim DmisApp As Object
Dim DmisPart As Object
Dim DmisCommands As Object
Dim DmisCommand As Object

  Set DmisApp = CreateObject("PCDLRN.Application")
  Set DmisPart = DmisApp.ActivePartProgram
  Set DmisCommands = DmisPart.Commands
  CommandCount = DmisCommands.Count
  Set DmisCommand = DmisCommands.Item(CommandCount)
  DmisCommands.InsertionPointAfter DmisCommand
  
  Set DmisCommand = DmisCommands.Add(SET_COMMENT, TRUE)
    DmisCommand.Marked = TRUE
  ' Set Id  = C1
    retval = DmisCommand.PutText ("C1", ID, 0)
  ' Set Comment Type  = INPUT
    retval = DmisCommand.SetToggleString (3, COMMENT_TYPE, 0)
  ' Set Comment Item 1 = 'WORKS ORDER NO'
    retval = DmisCommand.PutText ("WORKS ORDER NO", COMMENT_FIELD, 1)
  ' Set Report  = YES
    retval = DmisCommand.SetToggleString (2, OUTPUT_TYPE, 0)
  
  Set DmisCommand = DmisCommands.Add(SET_COMMENT, TRUE)
    DmisCommand.Marked = TRUE
  ' Set Id  = C2
    retval = DmisCommand.PutText ("C2", ID, 0)
  ' Set Comment Type  = INPUT
    retval = DmisCommand.SetToggleString (3, COMMENT_TYPE, 0)
  ' Set Comment Item 1 = 'CUSTOMERS ORDER NO'
    retval = DmisCommand.PutText ("CUSTOMERS ORDER NO", COMMENT_FIELD, 1)
  ' Set Report  = YES
    retval = DmisCommand.SetToggleString (2, OUTPUT_TYPE, 0)
  
  Set DmisCommand = DmisCommands.Add(SET_COMMENT, TRUE)
    DmisCommand.Marked = TRUE
  ' Set Id  = C3
    retval = DmisCommand.PutText ("C3", ID, 0)
  ' Set Comment Type  = INPUT
    retval = DmisCommand.SetToggleString (3, COMMENT_TYPE, 0)
  ' Set Comment Item 1 = 'SERIAL NO & DATE'
    retval = DmisCommand.PutText ("SERIAL NO & DATE", COMMENT_FIELD, 1)
  ' Set Report  = YES
    retval = DmisCommand.SetToggleString (2, OUTPUT_TYPE, 0)
  
End Sub


Any help appreciated and be gentle as i'm a bit fuzzy after last nights beer Nauseated face

Cheers
Parents Reply Children
No Data