'--------------------------------------------------------------- '- '- Global Link Presentation Editing Program '- Jack Garvey 10/4/2004 '- '--------------------------------------------------------------- 'Global Variable Declarations Dim x As Integer Dim NumberOfFields As Integer Dim SearchVariable As String ' Variable passed to Findstrings that has Dim DoComboLoad As Integer ' array search text Dim FirstArrayItem As Integer Dim Section As String ' Variable to hold presentation slide selected Public ArrayNumber As Integer ' Array that has requested info for FindStrings Dim Amps As Integer ' Number of ampersands = number of records Dim SectionName As String Private Sub FindStrings() 'Find variable text and load string Dim sampletext As String For i = 0 To (Amps) ' take input variable you are searching for (global variable) If VName(i) = SearchVariable Then ArrayNumber = i + 1 sampletext = VName(i) End If Next i End Sub Private Sub BTNCancel_Click() ' make textboxes and labels invisible For i = 0 To 3 Text1(i).Visible = False LabelText(i).Visible = False Text1(i).ForeColor = vbDisabledText Text1(i).Enabled = False Next i Combo1.ListIndex = 0 Image1.Picture = LoadPicture(App.Path & "\blank.gif") ' Code to restore text boxes back to default ' edit on, others off BTNCancel.Enabled = False BTNSaveChanges.Enabled = False BTNEdit.Enabled = False End Sub Private Sub BTNEdit_Click() ' Button edit goes off, cancel and save changes ' goes on BTNCancel.Enabled = True BTNSaveChanges.Enabled = True BTNEdit.Enabled = False ' background of textboxes and protection ' turned off For i = 0 To 3 Text1(i).Enabled = True Text1(i).BackColor = vbWhite Text1(i).ForeColor = vbBlack Next i End Sub Private Sub TurnOnFields() For i = 0 To (NumberOfFields - 1) Text1(i).Visible = True LabelText(i).Visible = True Next i End Sub 'Reset Labels to 1-4 'Changed when GL OVerview Intro is run 'Need to change back Private Sub ResetLabels() LabelText(0).Caption = "1" LabelText(1).Caption = "2" LabelText(2).Caption = "3" LabelText(3).Caption = "4" 'Turn off all fields End Sub 'When data is loaded for editing and edit button hit 'fields with data are enabled 'Otherwise they are greyed out Private Sub ResetTextboxes() For i = 0 To 3 Text1(i).Visible = False LabelText(i).Visible = False Text1(i).BackColor = vbButtonFace Text1(i).ForeColor = vbDisabledText Next i End Sub Private Sub CopytoArray() ' Copy textbox to the array item it corresponds to 'What was the index number of the first number of the index --> FirstArrayItem 'How many text boxes did you have? ---> NumberOfFields 'Loop through number of items Dim Start Start = FirstArrayItem For i = 0 To (NumberOfFields - 1) VString(Start) = Text1(i).Text Start = Start + 1 Next i ' Test --> Make sure changes are going in the right places 'For i = 0 To (Amps - 1) 'Text6.Text = Text6.Text + VName(i) + "=" + VString(i) + "----->" 'Next i End Sub Private Sub ArraytoTextFile() Dim CompleteText As String ' Turn off the Cancel and Save Buttons BTNCancel.Enabled = False BTNSaveChanges.Enabled = False BTNEdit.Enabled = True ' Send all array items to text file For i = 0 To (Amps - 1) Text6.Text = Text6.Text + VName(i) + "=" + VString(i) + "&" Next i ' Copy everything from text6.text into a variable CompleteText = Text6.Text Open "PresentationsText.txt" For Output As #1 Print #1, CompleteText Close #1 End Sub Private Sub BTNSaveChanges_Click() Call CopytoArray Call ArraytoTextFile Call ResetTextboxes BTNEdit.Enabled = False MsgBox ("Changes Saved to Presentation") ' Clear Global Variables x = 0 NumberOfFields = 0 SearchVariable = "" ' array search text FirstArrayItem = 0 Section = "" ArrayNumber = 0 Amps = 0 SectionName = "" Text5.Text = "" Text6.Text = "" ' Run Form load to load new file Call Form_Load DoComboLoad = 0 End Sub Private Sub Combo1_Click() For i = 1 To 3 Text1(i).ForeColor = vbDisabledText Next i BTNCancel.Enabled = True 'GTSS Slide One Selected If Combo1.Text = "GTSS - Slide 1" Then SectionName = Combo1.Text Call ResetLabels Call ResetTextboxes NumberOfFields = 4 Call TurnOnFields Image1.Picture = LoadPicture(App.Path & "\GTSS_1.gif") ' First Search for String SearchVariable = "G11" Call FindStrings G11ArrayNumber = ArrayNumber - 1 FirstArrayItem = G11ArrayNumber Text1(0).Text = VString(G11ArrayNumber) ' Second Search for String SearchVariable = "G12" Call FindStrings G12ArrayNumber = ArrayNumber - 1 Text1(1).Text = VString(G12ArrayNumber) ' Third Search for String SearchVariable = "G13" Call FindStrings G13ArrayNumber = ArrayNumber - 1 Text1(2).Text = VString(G13ArrayNumber) ' Fourth Search for String SearchVariable = "G14" Call FindStrings G14ArrayNumber = ArrayNumber - 1 Text1(3).Text = VString(G14ArrayNumber) End If 'GTSS Slide Two Selected If Combo1.Text = "GTSS - Slide 2" Then SectionName = Combo1.Text Call ResetLabels Call ResetTextboxes NumberOfFields = 3 Call TurnOnFields LabelText(0).Caption = "Presenter's Name" LabelText(1).Caption = "Presentation Title" Image1.Picture = LoadPicture(App.Path & "\GTSS_2.gif") ' First Search for String SearchVariable = "G21" Call FindStrings G21ArrayNumber = ArrayNumber - 1 FirstArrayItem = G21ArrayNumber Text1(0).Text = VString(G21ArrayNumber) ' Second Search for String SearchVariable = "G22" Call FindStrings G22ArrayNumber = ArrayNumber - 1 Text1(1).Text = VString(G22ArrayNumber) ' Third Search for String SearchVariable = "G23" Call FindStrings G23ArrayNumber = ArrayNumber - 1 Text1(2).Text = VString(G23ArrayNumber) End If 'Global Link Overview Introduction Slide Selected If Combo1.Text = "GL Overview - Intro" Then SectionName = Combo1.Text Call ResetLabels Call ResetTextboxes NumberOfFields = 2 Call TurnOnFields LabelText(0).Caption = "Presenter's Name" LabelText(1).Caption = "Presentation Title" Image1.Picture = LoadPicture(App.Path & "\GLOver_intro.gif") ' First Search for String SearchVariable = "GI11" Call FindStrings GI11ArrayNumber = ArrayNumber - 1 FirstArrayItem = GI11ArrayNumber Text1(0).Text = VString(GI11ArrayNumber) ' Second Search for String SearchVariable = "GI12" Call FindStrings GI12ArrayNumber = ArrayNumber - 1 Text1(1).Text = VString(GI12ArrayNumber) End If 'Global Link Overview Slide One Selected If Combo1.Text = "GL Overview - Slide 1" Then SectionName = Combo1.Text Call ResetLabels Call ResetTextboxes NumberOfFields = 3 Call TurnOnFields Image1.Picture = LoadPicture(App.Path & "\GLOver_1.gif") ' First Search for String SearchVariable = "GO11" Call FindStrings GO11ArrayNumber = ArrayNumber - 1 FirstArrayItem = GO11ArrayNumber Text1(0).Text = VString(GO11ArrayNumber) ' Second Search for String SearchVariable = "GO12" Call FindStrings GO12ArrayNumber = ArrayNumber - 1 Text1(1).Text = VString(GO12ArrayNumber) ' Third Search for String SearchVariable = "GO13" Call FindStrings GO13ArrayNumber = ArrayNumber - 1 Text1(2).Text = VString(GO13ArrayNumber) End If 'Global Link Overview Slide Two Selected If Combo1.Text = "GL Overview - Slide 2" Then SectionName = Combo1.Text Call ResetLabels Call ResetTextboxes NumberOfFields = 4 Call TurnOnFields Image1.Picture = LoadPicture(App.Path & "\GLOver_2.gif") ' First Search for String SearchVariable = "GO21" Call FindStrings GO21ArrayNumber = ArrayNumber - 1 FirstArrayItem = GO21ArrayNumber Text1(0).Text = VString(GO21ArrayNumber) ' Second Search for String SearchVariable = "GO22" Call FindStrings GO22ArrayNumber = ArrayNumber - 1 Text1(1).Text = VString(GO22ArrayNumber) ' Third Search for String SearchVariable = "GO23" Call FindStrings GO23ArrayNumber = ArrayNumber - 1 Text1(2).Text = VString(GO23ArrayNumber) ' Fourth Search for String SearchVariable = "GO24" Call FindStrings GO24ArrayNumber = ArrayNumber - 1 Text1(3).Text = VString(GO24ArrayNumber) End If 'Global Link Overview Slide Three Selected If Combo1.Text = "GL Overview - Slide 3" Then SectionName = Combo1.Text Call ResetLabels Call ResetTextboxes NumberOfFields = 3 Call TurnOnFields Image1.Picture = LoadPicture(App.Path & "\GLOver_3.gif") ' First Search for String SearchVariable = "GO31" Call FindStrings GO31ArrayNumber = ArrayNumber - 1 FirstArrayItem = GO31ArrayNumber Text1(0).Text = VString(GO31ArrayNumber) ' Second Search for String SearchVariable = "GO32" Call FindStrings GO32ArrayNumber = ArrayNumber - 1 Text1(1).Text = VString(GO32ArrayNumber) ' Third Search for String SearchVariable = "GO33" Call FindStrings GO33ArrayNumber = ArrayNumber - 1 Text1(2).Text = VString(GO33ArrayNumber) End If 'Global Link Overview Slide Four Selected If Combo1.Text = "GL Overview - Slide 4" Then SectionName = Combo1.Text Call ResetLabels Call ResetTextboxes NumberOfFields = 4 Call TurnOnFields Image1.Picture = LoadPicture(App.Path & "\GLOver_4.gif") ' First Search for String SearchVariable = "GO41" Call FindStrings GO41ArrayNumber = ArrayNumber - 1 FirstArrayItem = GO41ArrayNumber Text1(0).Text = VString(GO41ArrayNumber) ' Second Search for String SearchVariable = "GO42" Call FindStrings GO42ArrayNumber = ArrayNumber - 1 Text1(1).Text = VString(GO42ArrayNumber) ' Third Search for String SearchVariable = "GO43" Call FindStrings GO43ArrayNumber = ArrayNumber - 1 Text1(2).Text = VString(GO43ArrayNumber) ' Fourth Search for String SearchVariable = "GO44" Call FindStrings GO44ArrayNumber = ArrayNumber - 1 Text1(3).Text = VString(GO44ArrayNumber) End If BTNEdit.Enabled = True End Sub Private Sub Form_Load() 'Form loads and the Drop Down Combo Box is filled. BTNEdit.Enabled = False ' textboxes start out blank, disabled and invisible Call ResetTextboxes 'If DoComboLoad = 1 Then 'DoComboLoad = 1 'Else 'DoComboLoad = 0 'End If If Combo1.ListCount < 1 Then 'Put in options Combo1.AddItem "Please Select Slide to Edit" Combo1.AddItem "GTSS - Slide 1" Combo1.AddItem "GTSS - Slide 2" Combo1.AddItem "GL Overview - Intro" Combo1.AddItem "GL Overview - Slide 1" Combo1.AddItem "GL Overview - Slide 2" Combo1.AddItem "GL Overview - Slide 3" Combo1.AddItem "GL Overview - Slide 4" Combo1.ListIndex = 0 End If 'Open file for input Dim tmpString As String 'Open Text File and load contents into tmpString Open "PresentationsText.txt" For Input As #1 tmpString = Input(LOF(1), #1) Close #1 Text5.Text = tmpString 'Create an array (variable name, string) 'What are the limits of the array? 'Find out how many "&"s there are in file 'Flash uses ampersands & to seperate records Dim StringLength As Integer ' What is the length of the string? Dim Currentposition As Integer ' position in string Dim SpecificCharacter As String ' Character that will be tested in loop Dim i As Integer ' Loop counter tmpString = Text5.Text ' Load up tmpString Amps = 0 ' Set initial count of ampersands to zero StringLength = Len(tmpString) Currentposition = 1 'Loop to search for ampersands For i = 1 To StringLength If Mid(tmpString, i, 1) = "&" Then Amps = Amps + 1 Next i 'This loop will repeat until it has gone through the number of records 'in the text file defined by the above routine 'Text5.Text = "" 'tmpString is already defined 'Start and end of name string Dim NamePosStart As Integer Dim NamePosEnd As Integer Dim NameStringLength As Integer Dim NameArrayNumber As Integer 'start and end of information in string Dim InfoStringPosStart As Integer Dim InfoStringPosEnd As Integer Dim InfoStringPosLength As Integer 'Variables indicating which number variable is being worked on 'in array Dim ArrayNumber As Integer Dim StringArrayNumber As Integer 'Used within Loop Dim StartingPosition 'Set all variables to Zero NamePosStart = 1 NamePosEnd = 0 InfoStringPosStart = 0 InfoStringPosEnd = 0 NameArrayNumber = 0 StringArrayNumber = 0 NameStringLength = 0 InfoStringPosLength = 0 StartingPosition = 1 'Start Loop Loop is indexed by record numbers For i = 0 To (Amps - 1) 'Use instr to seach for first = sign NamePosEnd = ((InStr(StartingPosition, tmpString, "=") - 1)) NameStringLength = (NamePosEnd - NamePosStart) + 1 VName(i) = Mid(tmpString, NamePosStart, NameStringLength) 'Set up next section for string search InfoStringPosStart = NamePosEnd + 2 'Use instr to seach for first & sign InfoStringPosEnd = ((InStr(InfoStringPosStart, tmpString, "&") - 1)) NameStringLength = (1 + (InfoStringPosEnd - InfoStringPosStart)) VString(i) = Mid(tmpString, InfoStringPosStart, NameStringLength) 'For next iteration in this area NamePosStart = InfoStringPosEnd + 2 StartingPosition = InfoStringPosEnd + 1 'Text6.Text = Text6.Text + ("VName=" & VName(i) & " " & ", VString=" & VString(i) & " ") Next i ' Turn Save feature off until it is available End Sub Private Sub MNUQuit_Click() End End Sub