Visual Basic Example #4

Here's an example which shows how you might have a user interactively "tag" symbols on a Milestones Professional schedule.  This process might be useful when you need to later update a schedule with data from a database. 
 

Public objproject, objmilestones, tasks, T As Object
Public stringtag As String

Sub main()
Dim filename As String

filename = InputBox("Enter a File Name", "Test VB Program", "c:\filename.mla")

Set objmilestones = GetObject(filename)

objmilestones.KeepScheduleOpen

'Maximize the Milestones window
objmilestones.MaximizeWindow

Form1.Show

End Sub
  

FORM1 CODE
Private Sub Command1_Click()

stringtag = Text1.Text

taskindex = objmilestones.GetTaskLineOfSelectedSymbol

If taskindex < 1 Then
If taskindex = 0 Then MsgBox "no symbol is selected"
If taskindex < 0 Then MsgBox "more than one symbol is selected"
GoTo forgetit
End If

symbolindex = objmilestones.GetSelectedSymbolInLine(taskindex)

If symbolindex < 1 Then
If symbolindex = 0 Then MsgBox "no symbol is selected"
If symbolindex < 0 Then MsgBox "more than one symbol is selected"
GoTo forgetit
End If

objmilestones.setsymbolproperty taskindex, symbolindex, "SymbolNotes", stringtag
objmilestones.refreshtask taskindex
forgetit:
End Sub

Private Sub Command2_Click()
Form1.Hide
End
End Sub

Private Sub Command3_Click()

'Dim taskindex, symbolindex, numtsks, numsymbols As Integer
Dim symbolindex As Integer, symbolindex2 As Integer
Dim taskindex As Integer, taskindex2 As Integer
Dim numsymbols As Integer


taskindex = objmilestones.GetTaskLineOfSelectedSymbol

If taskindex < 1 Then
If taskindex = 0 Then MsgBox "no symbol is selected"
If taskindex < 0 Then MsgBox "more than one symbol is selected"
GoTo forgetit
End If

symbolindex = objmilestones.GetSelectedSymbolInLine(taskindex)

If symbolindex < 1 Then
If symbolindex = 0 Then MsgBox "no symbol is selected"
If symbolindex < 0 Then MsgBox "more than one symbol is selected"
GoTo forgetit
End If

numtsks = objmilestones.getnumberoflines


numsymbols = objmilestones.getnumberofsymbolsinline(taskindex)

symbolindex2 = symbolindex + 1

If symbolindex2 > numsymbols Then 'move to the first symbol
  xxx: taskindex = taskindex + 1
    If taskindex > numtsks Then taskindex = 1
    symbolindex2 = 1
    numsymbols = objmilestones.getnumberofsymbolsinline(taskindex)
    If numsymbols > 0 Then GoTo allwell
    GoTo xxx
End If


allwell:
objmilestones.selectsymbolinline 0, 0
objmilestones.selectsymbolinline taskindex, symbolindex2
objmilestones.refreshtask taskindex

forgetit:
End Sub

To try this example:
Click here to download a Zip file (MilestonesVBExample4.Zip) containing VB Code to do this.  Most of the code is in the supporting Form (Form1).
 
Click here to visit our main programmer's page.