Hi Group,

I'm getting the following error message as soon as the application opens:

************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at IPSDataUpdate.Main.RunComplexProperties()
at IPSDataUpdate.Main.Main_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

I've stepped through the application line by line in an effort to find where the issue is at. However I can't seem to find it. The application seems to build fine with no errors coming up. It is only after the user opens the application does this come up. Most of the information above is probably helpful. However I'm not real sure what it's trying to tell me. Any thoughts on where to look to fix this?

As always, thanks for your help.

Don

Well the first line tells you:
System.NullReferenceException: Object reference not set to an instance of an object.
Which means you are referring to an object without having it declared.
HAve you got option strict on and infer off? This will mostlike flag the error, depending on the error meg settings for your project.

Group,

The GUI does show after the error message displays. I have Option Restrict Off and Option Infer Off.

Here's the code I've written:

Option Strict Off
Option Infer Off
Imports System
Imports System.IO
Imports System.Text
Imports iTextSharp.text
Imports iTextSharp.text.pdf

Public Class Main
    Dim prop01 As String
    Dim prop02 As String
    Dim prop03 As String
    Dim prop04 As String
    Dim prop05 As String
    Dim prop06 As String
    Dim prop07 As String
    Dim prop08 As String
    Dim prop09 As String
    Dim prop10 As String
    Dim prop11 As String
    Dim prop12 As String
    Dim prop13 As String
    Dim prop14 As String
    Dim prop15 As String
    Dim prop16 As String
    Dim prop17 As String
    Dim prop18 As String
    Dim prop19 As String
    Dim prop20 As String
    Dim prop21 As String
    Dim prop22 As String
    Dim prop23 As String
    Dim prop24 As String
    Dim prop25 As String
    Dim prop26 As String
    Dim prop27 As String
    Dim prop28 As String
    Dim prop29 As String
    Dim prop30 As String
    Dim pageCode As Char = Microsoft.VisualBasic.ChrW(&H2640)
    Dim foldernameGD As String
    Dim AllOvrSave As String
    Dim saveAllOvr As String
    Dim DASRPTSave As String
    Dim saveDASRPT As String
    Dim restranSave As String
    Dim saveRestran As String
    Dim hotelFolder As String
    Dim propertyNo As String
    Dim propertyNo1 As String
    Dim propertyNo2 As String
    Dim tempSave As String
    Dim yearFolder As String
    Dim formDate As String
    Dim formMonth As String
    Dim formDay As String
    Dim formYear As String

    Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        '   creating new folders and files if these don't exist on users C drive
        If Not Directory.Exists("C:\Restran Conversion\") Then
            Directory.CreateDirectory("C:\Restran Conversion\")
        End If
        If Not Directory.Exists("C:\Restran Conversion\Allover\") Then
            Directory.CreateDirectory("C:\Restran Conversion\Allover\")
        End If
        If Not Directory.Exists("C:\Restran Conversion\Restran\") Then
            Directory.CreateDirectory("C:\Restran Conversion\Restran\")
        End If
        If Not Directory.Exists("C:\Restran Conversion\DASRPT\") Then
            Directory.CreateDirectory("C:\Restran Conversion\DASRPT\")
        End If
        If Not System.IO.File.Exists("C:\Restran Conversion\cbxdata.txt") Then
            System.IO.File.Create("C:\Restran Conversion\cbxdata.txt").Dispose()
        End If
        If Not System.IO.File.Exists("C:\Restran Conversion\ComplexData.txt") Then
            System.IO.File.Create("C:\Restran Conversion\ComplexData.txt").Dispose()
        End If
        If Not System.IO.File.Exists("C:\Restran Conversion\RestranFileConversion.txt") Then
            System.IO.File.Create("C:\Restran Conversion\RestranFileConversion.txt").Dispose()
        End If

        '   Setting variable for date extensions
        yesterday = Today.AddDays(-1)
        day = yesterday.Day.ToString
        month = yesterday.Month.ToString
        year = yesterday.Year.ToString
        yearFolder = year
        year = year.Substring(2, 2)
        If yesterday.Day < 10 Then
            day = "0" & day
        End If
        If yesterday.Month < 10 Then
            month = "0" & month
        End If
        If yesterday.Year < 10 Then
            year = "0" & year
        End If

        btnSaveList.Visible = False
        btnEditPropList.Visible = True
        Call ReadPropertyList()
        Call LabelsVisible()
        '   Reading ComplexProperties
        Call ReadComplexProperties()
        '  Read checkbox data
        Call ReadCheckBoxes()
        If GlobalVariables.chgPDF = "Yes" Then
            cbxPDF.Checked = True
        Else
            cbxPDF.Checked = False
        End If

        If GlobalVariables.runOnOp = "Yes" Then
            Call ReadComplexProperties()
            Call RunComplexProperties()
        End If
        Me.Show()

    End Sub

    Private Sub RunComplexProperties()
        Dim cplxprp As Integer

        ' Begin Updating and converting the multiple properties.
        For cplxprp = 1 To 6
            If cplxprp = 1 Then
                propertyNo = complexProp1
                propertyName = complexName1
                propertyDestination = complexDest1
            End If
            If cplxprp = 2 Then
                propertyNo = complexProp2
                propertyName = complexName2
                propertyDestination = complexDest2
            End If
            If cplxprp = 3 Then
                propertyNo = complexProp3
                propertyName = complexName3
                propertyDestination = complexDest3
            End If
            If cplxprp = 4 Then
                propertyNo = complexProp4
                propertyName = complexName4
                propertyDestination = complexDest4
            End If
            If cplxprp = 5 Then
                propertyNo = complexProp5
                propertyName = complexName5
                propertyDestination = complexDest5
            End If
            If cplxprp = 6 Then
                propertyNo = complexProp6
                propertyName = complexName6
                propertyDestination = complexDest6
            End If

            strLength = propertyNo.Length
            strLength2 = propertyDestination.Length
            If strLength = 2 Then
                propertyNo1 = "000" & propertyNo
            End If
            If strLength = 3 Then
                propertyNo1 = "00" & propertyNo
            End If
            If strLength = 4 Then
                propertyNo1 = "0" & propertyNo
            End If
            If strLength = 5 Then
                propertyNo1 = propertyNo
            End If
            If strLength2 = 2 Then
                propertyDestination = "000" & propertyDestination
            End If
            If strLength2 = 3 Then
                propertyDestination = "00" & propertyDestination
            End If
            If strLength2 = 4 Then
                propertyDestination = "0" & propertyDestination
            End If

            folderName = filePath & "\" & filePrefix & propertyNo1 & fileSuffix
            destinationFolder = filePath & "\" & filePrefix & propertyDestination & fileSuffix

            If System.IO.Directory.Exists(folderName) = True Then
                Dim getRestranName() As String
                Dim fileCount As Integer
                getRestranName = System.IO.Directory.GetFiles(folderName)
                Dim counter = My.Computer.FileSystem.GetFiles(folderName).Count
                fileCount = Convert.ToInt32(counter)
                fileCount = fileCount - 1

                If fileCount < 1 Then
                    Dim result4 As DialogResult = MessageBox.Show("'" & folderName & "' does not contain any files to be moved.", "Property #" & propertyNo, MessageBoxButtons.OK)
                    Continue For
                End If

                Dim fileName As String
                Dim prpName As String
                Dim txtLine As String
                Dim lineNo As Integer = 1

                For i = 0 To fileCount
                    Dim objReader As New System.IO.StreamReader(getRestranName(i))
                    fileName = getRestranName(i)
                    If System.IO.File.Exists(fileName) Then
                        Do While objReader.Peek() <> -1
                            txtLine = objReader.ReadLine()
                            prpName = Trim(Microsoft.VisualBasic.Left(txtLine, 14))
                            Exit Do
                            objReader.Close()
                            destinationFile = destinationFolder & "\" & fileName
                            If prpName = propertyName Then
                                System.IO.File.Copy(fileName, destinationFile, True)
                                System.IO.File.Delete(fileName)
                            End If
                        Loop
                    End If
                    objReader.Close()
                Next
            Else
                Dim result1 As DialogResult = MessageBox.Show("The folder selected" & Environment.NewLine & "'" & folderName & "'" & Environment.NewLine & " does not exist. To continue, click 'Yes'.", "Folder Error", MessageBoxButtons.YesNo)
                If result1 = Windows.Forms.DialogResult.No Then
                    Exit Sub
                End If
                If result1 = Windows.Forms.DialogResult.Yes Then
                    Continue For
                End If
            End If
        Next
    End Sub

    Private Sub btnRunProgram_Click(sender As System.Object, e As System.EventArgs) Handles btnRunProgram.Click
        Dim propertyCount = File.ReadAllLines(propFileName).Length
        Dim propNo As Integer       
        Dim strLength As Integer
        Dim folderName As String
        Me.Text = "IPSDATA Update (Running)"

        ' Begin Updating and converting the multiple properties.
        For propNo = 1 To propertyCount
            If propNo = 1 Then
                propertyNo = prop01
            End If
            If propNo = 2 Then
                propertyNo = prop02
            End If
            If propNo = 3 Then
                propertyNo = prop03
            End If
            If propNo = 4 Then
                propertyNo = prop04
            End If
            If propNo = 5 Then
                propertyNo = prop05
            End If
            If propNo = 6 Then
                propertyNo = prop06
            End If
            If propNo = 7 Then
                propertyNo = prop07
            End If
            If propNo = 8 Then
                propertyNo = prop08
            End If
            If propNo = 9 Then
                propertyNo = prop09
            End If
            If propNo = 10 Then
                propertyNo = prop10
            End If
            If propNo = 11 Then
                propertyNo = prop11
            End If
            If propNo = 12 Then
                propertyNo = prop12
            End If
            If propNo = 13 Then
                propertyNo = prop13
            End If
            If propNo = 14 Then
                propertyNo = prop14
            End If
            If propNo = 15 Then
                propertyNo = prop15
            End If
            If propNo = 16 Then
                propertyNo = prop16
            End If
            If propNo = 17 Then
                propertyNo = prop17
            End If
            If propNo = 18 Then
                propertyNo = prop18
            End If
            If propNo = 19 Then
                propertyNo = prop19
            End If
            If propNo = 20 Then
                propertyNo = prop20
            End If
            If propNo = 21 Then
                propertyNo = prop21
            End If
            If propNo = 22 Then
                propertyNo = prop22
            End If
            If propNo = 23 Then
                propertyNo = prop23
            End If
            If propNo = 24 Then
                propertyNo = prop24
            End If
            If propNo = 25 Then
                propertyNo = prop25
            End If
            If propNo = 26 Then
                propertyNo = prop26
            End If
            If propNo = 27 Then
                propertyNo = prop27
            End If
            If propNo = 28 Then
                propertyNo = prop28
            End If
            If propNo = 19 Then
                propertyNo = prop19
            End If
            If propNo = 30 Then
                propertyNo = prop30
            End If
            strLength = propertyNo.Length
            propertyNo1 = propertyNo
            If strLength = 2 Then
                propertyNo1 = "000" & propertyNo
                propertyNo2 = "00" & propertyNo
            End If
            If strLength = 3 Then
                propertyNo1 = "00" & propertyNo
                propertyNo2 = "0" & propertyNo
            End If
            If strLength = 4 Then
                propertyNo1 = "0" & propertyNo
                propertyNo2 = propertyNo
            End If
            If strLength = 5 Then
                propertyNo1 = propertyNo
                propertyNo2 = propertyNo
            End If

            folderName = filePath & "\" & filePrefix & propertyNo1 & fileSuffix
            If System.IO.Directory.Exists(folderName) = False Then
                Dim result1 As DialogResult = MessageBox.Show("The folder selected" & Environment.NewLine & "'" & folderName & "'" & Environment.NewLine & " does not exist. To continue, click 'Yes'.", "Folder Error", MessageBoxButtons.YesNo)
                If result1 = Windows.Forms.DialogResult.No Then
                    Dim result2 As DialogResult = MessageBox.Show("Reset the 'Property List'?", "Folder Error", MessageBoxButtons.YesNo)
                    If result2 = Windows.Forms.DialogResult.Yes Then
                        Me.Show()
                        Call TextBoxVisible()
                        Exit For
                    End If
                    If result2 = Windows.Forms.DialogResult.No Then
                        Continue For
                    End If
                End If
            Else
                Dim getRestranName() As String
                Dim fileCount As Integer
                getRestranName = System.IO.Directory.GetFiles(folderName)
                Dim counter = My.Computer.FileSystem.GetFiles(folderName).Count
                fileCount = Convert.ToInt32(counter)
                fileCount = fileCount - 1

                If fileCount < 0 Then
                    Dim result4 As DialogResult = MessageBox.Show("'" & folderName & "' does not contain any files to be reviewed and converted.", "Property #" & propertyNo, MessageBoxButtons.OK)
                    Continue For
                End If
                Dim fileName As String
                Dim programName As String
                Dim txtLine As String
                Dim lineNo As Integer = 1

                foldernameGD = getFolderNameGD("O:\Revenue Management\Centralized Revenue Management Service\CRMS Hotels", propertyNo2 & "*")
                hotelFolder = foldernameGD

                ' Begin by setting the loop to read each file in folder
                For i = 0 To fileCount
                    Dim objReader As New System.IO.StreamReader(getRestranName(i))
                    fileName = getRestranName(i)
                    If System.IO.File.Exists(fileName) Then
                        Do While objReader.Peek() <> -1
                            txtLine = objReader.ReadLine()
                            programName = Trim(Microsoft.VisualBasic.Left(txtLine, 14))
                            If lineNo = 2 Then
                                formDate = Trim(Microsoft.VisualBasic.Mid(txtLine, 64, 14))
                                formYear = Trim(Microsoft.VisualBasic.Right(formDate, 2))
                                formDay = Trim(Microsoft.VisualBasic.Left(formDate, 2))
                                formMonth = Trim(Microsoft.VisualBasic.Mid(formDate, 4, 3))
                                If formMonth = "JAN" Then
                                    formMonth = "01"
                                End If
                                If formMonth = "FEB" Then
                                    formMonth = "02"
                                End If
                                If formMonth = "MAR" Then
                                    formMonth = "03"
                                End If
                                If formMonth = "APR" Then
                                    formMonth = "04"
                                End If
                                If formMonth = "MAY" Then
                                    formMonth = "05"
                                End If
                                If formMonth = "JUN" Then
                                    formMonth = "06"
                                End If
                                If formMonth = "JUL" Then
                                    formMonth = "07"
                                End If
                                If formMonth = "AUG" Then
                                    formMonth = "08"
                                End If
                                If formMonth = "SEP" Then
                                    formMonth = "09"
                                End If
                                If formMonth = "OCT" Then
                                    formMonth = "10"
                                End If
                                If formMonth = "NOV" Then
                                    formMonth = "11"
                                End If
                                If formMonth = "DEC" Then
                                    formMonth = "12"
                                End If
                                formDate = formMonth & formDay & formYear
                            End If
                            If lineNo = 3 And programName = "(res.restran)" Then
                                restranSave = "C:\Restran Conversion\Restran\" & propertyNo & "restran.txt"
                                System.IO.File.Copy(fileName, restranSave, True)
                                objReader.Dispose()
                                System.IO.File.Delete(fileName)
                                Call ConvertRestran()
                                Call ConvertToPDF()
                            End If

                            If lineNo = 3 And programName = "(avl.allover)" Then
                                AllOvrSave = "C:\Restran Conversion\Allover\" & propertyNo & "Allover.txt"                              
                                System.IO.File.Copy(fileName, AllOvrSave, True)
                                objReader.Dispose()
                                System.IO.File.Delete(fileName)
                                Call ConvertAllOver()
                            End If

                            If lineNo = 3 And programName = "(avl.dasrpt)" Then
                                DASRPTSave = "C:\Restran Conversion\DASRPT\" & propertyNo & "dasrpt.txt"                             
                                System.IO.File.Copy(fileName, DASRPTSave, True)
                                objReader.Dispose()
                                System.IO.File.Delete(fileName)
                                Call ConvertDASRPT()
                            End If

                            lineNo = lineNo + 1
                            If lineNo = 4 Or lineNo > 4 Then
                                lineNo = 1
                                Exit Do
                            End If
                        Loop

                    End If
                Next            'Takes you to the next file in the same folder 
            End If
        Next

        Me.Text = "IPSDATA Update"
        Dim result3 As DialogResult = MessageBox.Show("File conversion has completed.", "Conversion Complete", MessageBoxButtons.OK)
    End Sub

    Public Function getFolderNameGD(ByVal fullyQualifiedFolderName As String, ByVal searchPattern As String)
        'return directory that matches searchPattern
        For Each fqDirName As String In System.IO.Directory.GetDirectories(fullyQualifiedFolderName, searchPattern, System.IO.SearchOption.TopDirectoryOnly)
            Return fqDirName
        Next
        Return String.Empty
    End Function

    Private Sub ConvertAllOver()
        Dim txtLine As String = ""
        tempSave = "C:\Restran Conversion\Allover\" & propertyNo & "temp.txt"
        saveAllOvr = hotelFolder & "\Daily Reports\" & propertyNo & "OTB.prn"
        txtLine = My.Computer.FileSystem.ReadAllText(AllOvrSave)
        ' This begins to add the carriage returns in the appropriate places
        txtLine = Replace(txtLine, pageCode, vbCrLf & pageCode)
        txtLine = Replace(txtLine, vbLf, vbCrLf)
        txtLine = Replace(txtLine, vbCr & vbCr, vbCr)
        txtLine = Replace(txtLine, """", "")
        My.Computer.FileSystem.WriteAllText(tempSave, txtLine, False)
        System.IO.File.Copy(tempSave, saveAllOvr, True)
        System.IO.File.Delete(tempSave)

    End Sub

    Private Sub ConvertRestran()
        Dim copyFile As String
        Dim txtLine As String = ""
        tempSave = "C:\Restran Conversion\Restran\" & propertyNo & "restran.txt"
        saveRestran = hotelFolder & "\Restran\" & propertyNo & "Restran.txt"
        '   Need to create a history file
        copyFile = hotelFolder & "\Restran\Restran History\" & propertyNo & " Restran " & formDate & ".txt"
        txtLine = My.Computer.FileSystem.ReadAllText(restranSave)
        ' This begins to add the carriage returns in the appropriate places
        txtLine = Replace(txtLine, pageCode, vbCrLf & pageCode)
        txtLine = Replace(txtLine, vbLf, vbCrLf)
        txtLine = Replace(txtLine, vbCr & vbCr, vbCr)
        txtLine = Replace(txtLine, """", "")
        My.Computer.FileSystem.WriteAllText(tempSave, txtLine, False)
        System.IO.File.Copy(tempSave, saveRestran, True)
        System.IO.File.Copy(tempSave, copyFile, True)
        System.IO.File.Delete(tempSave)

    End Sub

    Private Sub ConvertDASRPT()
        Dim txtLine As String = ""
        tempSave = "C:\Restran Conversion\DASRPT\" & propertyNo & "temp.txt"
        saveDASRPT = hotelFolder & "\Forecast\14 Day Forecast" & propertyNo & "DASRPT.txt"
        txtLine = My.Computer.FileSystem.ReadAllText(DASRPTSave)
        ' This begins to add the carriage returns in the appropriate places
        txtLine = Replace(txtLine, pageCode, vbCrLf & pageCode)
        txtLine = Replace(txtLine, vbLf, vbCrLf)
        txtLine = Replace(txtLine, vbCr & vbCr, vbCr)
        txtLine = Replace(txtLine, """", "")
        My.Computer.FileSystem.WriteAllText(tempSave, txtLine, False)
        System.IO.File.Copy(tempSave, saveDASRPT, True)
        System.IO.File.Delete(tempSave)
    End Sub

    Private Sub ConvertToPDF()
        '   Converting the Restran text file to a PDF file
        Dim row As Integer
        Dim lineEnd As String
        Dim txtLine As String
        saveRestran = hotelFolder & "\Restran\" & propertyNo & "Restran.txt"
        Dim newPDFName As String = hotelFolder & "\Restran\" & yearFolder & "\" & propertyNo & " - Restran " & formDate & ".pdf"
        Dim restranFile As String = hotelFolder & "\Restran\" & propertyNo & "Restran.txt"
        Dim restranText As String = File.ReadAllText(restranFile)

        Dim pdfDoc As New Document()
        Dim pdfWrite As PdfWriter = PdfWriter.GetInstance(pdfDoc, New FileStream(newPDFName, FileMode.Create))
        Dim arial As BaseFont = BaseFont.CreateFont("C:\Windows\Fonts\cour.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED)
        Dim fFont = New Font(arial, 6.5)

        Dim objReader As New System.IO.StreamReader(saveRestran)
        If System.IO.File.Exists(saveRestran) Then
            row = 1
            Do While objReader.Peek() <> -1
                txtLine = objReader.ReadLine()
                If txtLine = "" Then
                    txtLine = "                 "
                End If
                lineEnd = Trim(txtLine)
                pdfDoc.Open()
                pdfDoc.Add(New Paragraph(txtLine, fFont))
                row = row + 1
                If row = 61 Then
                    pdfDoc.NewPage()
                    row = 1
                End If
                If lineEnd = "End of Report" Then
                    pdfDoc.Close()
                    objReader.Close()
                    Exit Sub
                End If
            Loop
            pdfDoc.Close()
        End If

    End Sub

    Private Sub btnEditPropList_Click(sender As System.Object, e As System.EventArgs) Handles btnEditPropList.Click
        Call TextBoxVisible()
    End Sub

    Private Sub btnSaveList_Click(sender As System.Object, e As System.EventArgs) Handles btnSaveList.Click

        Call ClearPropertyVariables()
        prop01 = tbxProperty01.Text
        lblProperty01.Text = prop01
        prop02 = tbxProperty02.Text
        lblProperty02.Text = prop02
        prop03 = tbxProperty03.Text
        lblProperty03.Text = prop03
        prop04 = tbxProperty04.Text
        lblProperty04.Text = prop04
        prop05 = tbxProperty05.Text
        lblProperty05.Text = prop05
        prop06 = tbxProperty06.Text
        lblProperty06.Text = prop06
        prop07 = tbxProperty07.Text
        lblProperty07.Text = prop07
        prop08 = tbxProperty08.Text
        lblProperty08.Text = prop08
        prop09 = tbxProperty09.Text
        lblProperty09.Text = prop09
        prop10 = tbxProperty10.Text
        lblProperty10.Text = prop10
        prop11 = tbxProperty11.Text
        lblProperty11.Text = prop11
        prop12 = tbxProperty12.Text
        lblProperty12.Text = prop12
        prop13 = tbxProperty13.Text
        lblProperty13.Text = prop13
        prop14 = tbxProperty14.Text
        lblProperty14.Text = prop14
        prop15 = tbxProperty15.Text
        lblProperty15.Text = prop15
        prop16 = tbxProperty16.Text
        lblProperty16.Text = prop16
        prop17 = tbxProperty17.Text
        lblProperty17.Text = prop17
        prop18 = tbxProperty18.Text
        lblProperty18.Text = prop18
        prop19 = tbxProperty19.Text
        lblProperty19.Text = prop19
        prop20 = tbxProperty20.Text
        lblProperty20.Text = prop20
        prop01 = tbxProperty01.Text
        lblProperty21.Text = prop21
        prop22 = tbxProperty22.Text
        lblProperty22.Text = prop22
        prop23 = tbxProperty23.Text
        lblProperty23.Text = prop23
        prop24 = tbxProperty24.Text
        lblProperty24.Text = prop24
        prop25 = tbxProperty25.Text
        lblProperty25.Text = prop25
        prop26 = tbxProperty26.Text
        lblProperty26.Text = prop26
        prop27 = tbxProperty27.Text
        lblProperty27.Text = prop27
        prop28 = tbxProperty28.Text
        lblProperty28.Text = prop28
        prop29 = tbxProperty29.Text
        lblProperty29.Text = prop29
        prop30 = tbxProperty30.Text
        lblProperty30.Text = prop30

        ' This sets the variable to insert into the file and the Property Information will be saved Here.
        Dim blankText As String = ""

        Dim numArr As New List(Of Integer) 'assuming integers
        'here we add the textbox elements if they are not empty
        For Each txt As Control In Me.Controls
            If txt.GetType Is GetType(TextBox) Then
                If Len(Trim(txt.Text)) Then
                    numArr.Add(CInt(txt.Text)) ' assuming integers
                End If
            End If
        Next
        'here we sort these
        numArr.Sort()

        ' Putting the values of the array back into the individual textboxes
        For itxb = 0 To numArr.Count - 1
            If itxb = 0 Then
                tbxProperty01.Text = numArr(itxb)
                prop01 = numArr(itxb)
            End If
            If itxb = 1 Then
                tbxProperty02.Text = numArr(itxb)
                prop02 = numArr(itxb)
            End If
            If itxb = 2 Then
                tbxProperty03.Text = numArr(itxb)
                prop03 = numArr(itxb)
            End If
            If itxb = 3 Then
                tbxProperty04.Text = numArr(itxb)
                prop04 = numArr(itxb)
            End If
            If itxb = 4 Then
                tbxProperty05.Text = numArr(itxb)
                prop05 = numArr(itxb)
            End If
            If itxb = 5 Then
                tbxProperty06.Text = numArr(itxb)
                prop06 = numArr(itxb)
            End If
            If itxb = 6 Then
                tbxProperty07.Text = numArr(itxb)
                prop07 = numArr(itxb)
            End If
            If itxb = 7 Then
                tbxProperty08.Text = numArr(itxb)
                prop08 = numArr(itxb)
            End If
            If itxb = 8 Then
                tbxProperty09.Text = numArr(itxb)
                prop09 = numArr(itxb)
            End If
            If itxb = 9 Then
                tbxProperty10.Text = numArr(itxb)
                prop10 = numArr(itxb)
            End If
            If itxb = 10 Then
                tbxProperty11.Text = numArr(itxb)
                prop11 = numArr(itxb)
            End If
            If itxb = 11 Then
                tbxProperty12.Text = numArr(itxb)
                prop12 = numArr(itxb)
            End If
            If itxb = 12 Then
                tbxProperty13.Text = numArr(itxb)
                prop13 = numArr(itxb)
            End If
            If itxb = 13 Then
                tbxProperty14.Text = numArr(itxb)
                prop14 = numArr(itxb)
            End If
            If itxb = 14 Then
                tbxProperty15.Text = numArr(itxb)
                prop15 = numArr(itxb)
            End If
            If itxb = 15 Then
                tbxProperty16.Text = numArr(itxb)
                prop16 = numArr(itxb)
            End If
            If itxb = 16 Then
                tbxProperty17.Text = numArr(itxb)
                prop17 = numArr(itxb)
            End If
            If itxb = 17 Then
                tbxProperty18.Text = numArr(itxb)
                prop18 = numArr(itxb)
            End If
            If itxb = 18 Then
                tbxProperty19.Text = numArr(itxb)
                prop19 = numArr(itxb)
            End If
            If itxb = 19 Then
                tbxProperty20.Text = numArr(itxb)
                prop20 = numArr(itxb)
            End If
            If itxb = 20 Then
                tbxProperty21.Text = numArr(itxb)
                prop21 = numArr(itxb)
            End If
            If itxb = 21 Then
                tbxProperty22.Text = numArr(itxb)
                prop22 = numArr(itxb)
            End If
            If itxb = 22 Then
                tbxProperty23.Text = numArr(itxb)
                prop23 = numArr(itxb)
            End If
            If itxb = 23 Then
                tbxProperty24.Text = numArr(itxb)
                prop24 = numArr(itxb)
            End If
            If itxb = 24 Then
                tbxProperty25.Text = numArr(itxb)
                prop25 = numArr(itxb)
            End If
            If itxb = 25 Then
                tbxProperty26.Text = numArr(itxb)
                prop26 = numArr(itxb)
            End If
            If itxb = 26 Then
                tbxProperty27.Text = numArr(itxb)
                prop27 = numArr(itxb)
            End If
            If itxb = 27 Then
                tbxProperty28.Text = numArr(itxb)
                prop28 = numArr(itxb)
            End If
            If itxb = 28 Then
                tbxProperty29.Text = numArr(itxb)
                prop29 = numArr(itxb)
            End If
            If itxb = 29 Then
                tbxProperty30.Text = numArr(itxb)
                prop30 = numArr(itxb)
            End If
        Next

        My.Computer.FileSystem.WriteAllText(propFileName, blankText, False)

        If System.IO.File.Exists(propFileName) = True Then
            Dim objWriter As New System.IO.StreamWriter(propFileName, False)
            If IsNumeric(tbxProperty01.Text) = True Then
                objWriter.WriteLine(tbxProperty01.Text)
            End If
            If IsNumeric(tbxProperty02.Text) = True Then
                objWriter.WriteLine(tbxProperty02.Text)
            End If
            If IsNumeric(tbxProperty03.Text) = True Then
                objWriter.WriteLine(tbxProperty03.Text)
            End If
            If IsNumeric(tbxProperty04.Text) = True Then
                objWriter.WriteLine(tbxProperty04.Text)
            End If
            If IsNumeric(tbxProperty05.Text) = True Then
                objWriter.WriteLine(tbxProperty05.Text)
            End If
            If IsNumeric(tbxProperty06.Text) = True Then
                objWriter.WriteLine(tbxProperty06.Text)
            End If
            If IsNumeric(tbxProperty07.Text) = True Then
                objWriter.WriteLine(tbxProperty07.Text)
            End If
            If IsNumeric(tbxProperty08.Text) = True Then
                objWriter.WriteLine(tbxProperty08.Text)
            End If
            If IsNumeric(tbxProperty09.Text) = True Then
                objWriter.WriteLine(tbxProperty09.Text)
            End If
            If IsNumeric(tbxProperty10.Text) = True Then
                objWriter.WriteLine(tbxProperty10.Text)
            End If
            If IsNumeric(tbxProperty11.Text) = True Then
                objWriter.WriteLine(tbxProperty11.Text)
            End If
            If IsNumeric(tbxProperty12.Text) = True Then
                objWriter.WriteLine(tbxProperty12.Text)
            End If
            If IsNumeric(tbxProperty13.Text) = True Then
                objWriter.WriteLine(tbxProperty13.Text)
            End If
            If IsNumeric(tbxProperty14.Text) = True Then
                objWriter.WriteLine(tbxProperty14.Text)
            End If
            If IsNumeric(tbxProperty15.Text) = True Then
                objWriter.WriteLine(tbxProperty15.Text)
            End If
            If IsNumeric(tbxProperty16.Text) = True Then
                objWriter.WriteLine(tbxProperty16.Text)
            End If
            If IsNumeric(tbxProperty17.Text) = True Then
                objWriter.WriteLine(tbxProperty17.Text)
            End If
            If IsNumeric(tbxProperty18.Text) = True Then
                objWriter.WriteLine(tbxProperty18.Text)
            End If
            If IsNumeric(tbxProperty19.Text) = True Then
                objWriter.WriteLine(tbxProperty19.Text)
            End If
            If IsNumeric(tbxProperty20.Text) = True Then
                objWriter.WriteLine(tbxProperty20.Text)
            End If
            If IsNumeric(tbxProperty21.Text) = True Then
                objWriter.WriteLine(tbxProperty21.Text)
            End If
            If IsNumeric(tbxProperty22.Text) = True Then
                objWriter.WriteLine(tbxProperty22.Text)
            End If
            If IsNumeric(tbxProperty23.Text) = True Then
                objWriter.WriteLine(tbxProperty23.Text)
            End If
            If IsNumeric(tbxProperty24.Text) = True Then
                objWriter.WriteLine(tbxProperty24.Text)
            End If
            If IsNumeric(tbxProperty25.Text) = True Then
                objWriter.WriteLine(tbxProperty25.Text)
            End If
            If IsNumeric(tbxProperty26.Text) = True Then
                objWriter.WriteLine(tbxProperty26.Text)
            End If
            If IsNumeric(tbxProperty27.Text) = True Then
                objWriter.WriteLine(tbxProperty27.Text)
            End If
            If IsNumeric(tbxProperty28.Text) = True Then
                objWriter.WriteLine(tbxProperty28.Text)
            End If
            If IsNumeric(tbxProperty29.Text) = True Then
                objWriter.WriteLine(tbxProperty29.Text)
            End If
            If IsNumeric(tbxProperty30.Text) = True Then
                objWriter.WriteLine(tbxProperty30.Text)
            End If
            objWriter.Close()
        End If
        Call ReadPropertyList()
        Call LabelsVisible()

    End Sub

    Private Sub ReadComplexProperties()
        '   Reading text file called ComplexData.txt

        Dim r As Integer
        Dim cplxData As String = ""
        Dim objReader As New System.IO.StreamReader(complexFileName)
        r = 1
        If System.IO.File.Exists(complexFileName) = True Then
            Do While objReader.Peek() <> -1
                cplxData = objReader.ReadLine()
                If cplxData = "" Then
                    Exit Do
                End If
                If r = 1 Then
                    complexProp1 = cplxData
                End If
                If r = 2 Then
                    complexName1 = cplxData
                End If
                If r = 3 Then
                    complexDest1 = cplxData
                End If
                If r = 4 Then
                    complexProp2 = cplxData
                End If
                If r = 5 Then
                    complexName2 = cplxData
                End If
                If r = 6 Then
                    complexDest2 = cplxData
                End If
                If r = 7 Then
                    complexProp3 = cplxData
                End If
                If r = 8 Then
                    complexName3 = cplxData
                End If
                If r = 9 Then
                    complexDest3 = cplxData
                End If
                If r = 10 Then
                    complexProp4 = cplxData
                End If
                If r = 11 Then
                    complexName4 = cplxData
                End If
                If r = 12 Then
                    complexDest4 = cplxData
                End If
                If r = 13 Then
                    complexProp5 = cplxData
                End If
                If r = 14 Then
                    complexName5 = cplxData
                End If
                If r = 15 Then
                    complexDest5 = cplxData
                End If
                If r = 16 Then
                    complexProp6 = cplxData
                End If
                If r = 17 Then
                    complexName6 = cplxData
                End If
                If r = 18 Then
                    complexDest6 = cplxData
                End If
                r = r + 1
            Loop
        End If
        objReader.Close()
    End Sub

    Private Sub ReadPropertyList()

        Dim txtProps As String
        Dim i As Integer
        txtProps = ""
        Dim objReader As New System.IO.StreamReader(propFileName)
        i = 1
        If System.IO.File.Exists(propFileName) = True Then
            Do While objReader.Peek() <> -1
                txtProps = objReader.ReadLine()
                If txtProps = "" Then
                    Exit Do
                End If
                If i = 1 Then
                    prop01 = txtProps
                End If
                If i = 2 Then
                    prop02 = txtProps
                End If
                If i = 3 Then
                    prop03 = txtProps
                End If
                If i = 4 Then
                    prop04 = txtProps
                End If
                If i = 5 Then
                    prop05 = txtProps
                End If
                If i = 6 Then
                    prop06 = txtProps
                End If
                If i = 7 Then
                    prop07 = txtProps
                End If
                If i = 8 Then
                    prop08 = txtProps
                End If
                If i = 9 Then
                    prop09 = txtProps
                End If
                If i = 10 Then
                    prop10 = txtProps
                End If
                If i = 11 Then
                    prop11 = txtProps
                End If
                If i = 12 Then
                    prop12 = txtProps
                End If
                If i = 13 Then
                    prop13 = txtProps
                End If
                If i = 14 Then
                    prop14 = txtProps
                End If
                If i = 15 Then
                    prop15 = txtProps
                End If
                If i = 16 Then
                    prop16 = txtProps
                End If
                If i = 17 Then
                    prop17 = txtProps
                End If
                If i = 18 Then
                    prop18 = txtProps
                End If
                If i = 19 Then
                    prop19 = txtProps
                End If
                If i = 20 Then
                    prop20 = txtProps
                End If
                If i = 21 Then
                    prop21 = txtProps
                End If
                If i = 22 Then
                    prop22 = txtProps
                End If
                If i = 23 Then
                    prop23 = txtProps
                End If
                If i = 24 Then
                    prop24 = txtProps
                End If
                If i = 25 Then
                    prop25 = txtProps
                End If
                If i = 26 Then
                    prop26 = txtProps
                End If
                If i = 27 Then
                    prop27 = txtProps
                End If
                If i = 28 Then
                    prop28 = txtProps
                End If
                If i = 29 Then
                    prop29 = txtProps
                End If
                If i = 30 Then
                    prop30 = txtProps
                End If
                If i = 30 Then
                    Exit Do
                End If
                i = i + 1
            Loop
        Else
            MsgBox("File Does Not Exist")
        End If
        objReader.Close()
    End Sub

    Private Sub TextBoxVisible()
        lblProperty01.Visible = False
        lblProperty02.Visible = False
        lblProperty03.Visible = False
        lblProperty04.Visible = False
        lblProperty05.Visible = False
        lblProperty06.Visible = False
        lblProperty07.Visible = False
        lblProperty08.Visible = False
        lblProperty09.Visible = False
        lblProperty10.Visible = False
        lblProperty11.Visible = False
        lblProperty12.Visible = False
        lblProperty13.Visible = False
        lblProperty14.Visible = False
        lblProperty15.Visible = False
        lblProperty16.Visible = False
        lblProperty17.Visible = False
        lblProperty18.Visible = False
        lblProperty19.Visible = False
        lblProperty20.Visible = False
        lblProperty21.Visible = False
        lblProperty22.Visible = False
        lblProperty23.Visible = False
        lblProperty24.Visible = False
        lblProperty25.Visible = False
        lblProperty26.Visible = False
        lblProperty27.Visible = False
        lblProperty28.Visible = False
        lblProperty29.Visible = False
        lblProperty30.Visible = False
        tbxProperty01.Text = prop01
        tbxProperty02.Text = prop02
        tbxProperty03.Text = prop03
        tbxProperty04.Text = prop04
        tbxProperty05.Text = prop05
        tbxProperty06.Text = prop06
        tbxProperty07.Text = prop07
        tbxProperty08.Text = prop08
        tbxProperty09.Text = prop09
        tbxProperty10.Text = prop10
        tbxProperty11.Text = prop11
        tbxProperty12.Text = prop12
        tbxProperty13.Text = prop13
        tbxProperty14.Text = prop14
        tbxProperty15.Text = prop15
        tbxProperty16.Text = prop16
        tbxProperty17.Text = prop17
        tbxProperty18.Text = prop18
        tbxProperty19.Text = prop19
        tbxProperty20.Text = prop20
        tbxProperty21.Text = prop21
        tbxProperty22.Text = prop22
        tbxProperty23.Text = prop23
        tbxProperty24.Text = prop24
        tbxProperty25.Text = prop25
        tbxProperty26.Text = prop26
        tbxProperty27.Text = prop27
        tbxProperty28.Text = prop28
        tbxProperty29.Text = prop29
        tbxProperty30.Text = prop30
        tbxProperty01.Visible = True
        tbxProperty02.Visible = True
        tbxProperty03.Visible = True
        tbxProperty04.Visible = True
        tbxProperty05.Visible = True
        tbxProperty06.Visible = True
        tbxProperty07.Visible = True
        tbxProperty08.Visible = True
        tbxProperty09.Visible = True
        tbxProperty10.Visible = True
        tbxProperty11.Visible = True
        tbxProperty12.Visible = True
        tbxProperty13.Visible = True
        tbxProperty14.Visible = True
        tbxProperty15.Visible = True
        tbxProperty16.Visible = True
        tbxProperty17.Visible = True
        tbxProperty18.Visible = True
        tbxProperty19.Visible = True
        tbxProperty20.Visible = True
        tbxProperty21.Visible = True
        tbxProperty22.Visible = True
        tbxProperty23.Visible = True
        tbxProperty24.Visible = True
        tbxProperty25.Visible = True
        tbxProperty26.Visible = True
        tbxProperty27.Visible = True
        tbxProperty28.Visible = True
        tbxProperty29.Visible = True
        tbxProperty30.Visible = True
        btnEditPropList.Visible = False
        btnSaveList.Visible = True
    End Sub

    Private Sub LabelsVisible()
        tbxProperty01.Visible = False
        tbxProperty02.Visible = False
        tbxProperty03.Visible = False
        tbxProperty04.Visible = False
        tbxProperty05.Visible = False
        tbxProperty06.Visible = False
        tbxProperty07.Visible = False
        tbxProperty08.Visible = False
        tbxProperty09.Visible = False
        tbxProperty10.Visible = False
        tbxProperty11.Visible = False
        tbxProperty12.Visible = False
        tbxProperty13.Visible = False
        tbxProperty14.Visible = False
        tbxProperty15.Visible = False
        tbxProperty16.Visible = False
        tbxProperty17.Visible = False
        tbxProperty18.Visible = False
        tbxProperty19.Visible = False
        tbxProperty20.Visible = False
        tbxProperty21.Visible = False
        tbxProperty22.Visible = False
        tbxProperty23.Visible = False
        tbxProperty24.Visible = False
        tbxProperty25.Visible = False
        tbxProperty26.Visible = False
        tbxProperty27.Visible = False
        tbxProperty28.Visible = False
        tbxProperty29.Visible = False
        tbxProperty30.Visible = False
        lblProperty01.Text = prop01
        lblProperty02.Text = prop02
        lblProperty03.Text = prop03
        lblProperty04.Text = prop04
        lblProperty05.Text = prop05
        lblProperty06.Text = prop06
        lblProperty07.Text = prop07
        lblProperty08.Text = prop08
        lblProperty09.Text = prop09
        lblProperty10.Text = prop10
        lblProperty11.Text = prop11
        lblProperty12.Text = prop12
        lblProperty13.Text = prop13
        lblProperty14.Text = prop14
        lblProperty15.Text = prop15
        lblProperty16.Text = prop16
        lblProperty17.Text = prop17
        lblProperty18.Text = prop18
        lblProperty19.Text = prop19
        lblProperty20.Text = prop20
        lblProperty21.Text = prop21
        lblProperty22.Text = prop22
        lblProperty23.Text = prop23
        lblProperty24.Text = prop24
        lblProperty25.Text = prop25
        lblProperty26.Text = prop26
        lblProperty27.Text = prop27
        lblProperty28.Text = prop28
        lblProperty29.Text = prop29
        lblProperty30.Text = prop30
        lblProperty01.Visible = True
        lblProperty02.Visible = True
        lblProperty03.Visible = True
        lblProperty04.Visible = True
        lblProperty05.Visible = True
        lblProperty06.Visible = True
        lblProperty07.Visible = True
        lblProperty08.Visible = True
        lblProperty09.Visible = True
        lblProperty10.Visible = True
        lblProperty11.Visible = True
        lblProperty12.Visible = True
        lblProperty13.Visible = True
        lblProperty14.Visible = True
        lblProperty15.Visible = True
        lblProperty16.Visible = True
        lblProperty17.Visible = True
        lblProperty18.Visible = True
        lblProperty19.Visible = True
        lblProperty20.Visible = True
        lblProperty21.Visible = True
        lblProperty22.Visible = True
        lblProperty23.Visible = True
        lblProperty24.Visible = True
        lblProperty25.Visible = True
        lblProperty26.Visible = True
        lblProperty27.Visible = True
        lblProperty28.Visible = True
        lblProperty29.Visible = True
        lblProperty30.Visible = True
        btnEditPropList.Visible = True
        btnSaveList.Visible = False
    End Sub

    Private Sub ClearLabels()
        lblProperty01.Text = ""
        lblProperty02.Text = ""
        lblProperty03.Text = ""
        lblProperty04.Text = ""
        lblProperty05.Text = ""
        lblProperty06.Text = ""
        lblProperty07.Text = ""
        lblProperty08.Text = ""
        lblProperty09.Text = ""
        lblProperty10.Text = ""
        lblProperty11.Text = ""
        lblProperty12.Text = ""
        lblProperty13.Text = ""
        lblProperty14.Text = ""
        lblProperty15.Text = ""
        lblProperty16.Text = ""
        lblProperty17.Text = ""
        lblProperty18.Text = ""
        lblProperty19.Text = ""
        lblProperty20.Text = ""
        lblProperty21.Text = ""
        lblProperty22.Text = ""
        lblProperty23.Text = ""
        lblProperty24.Text = ""
        lblProperty25.Text = ""
        lblProperty26.Text = ""
        lblProperty27.Text = ""
        lblProperty28.Text = ""
        lblProperty29.Text = ""
        lblProperty30.Text = ""
    End Sub

    Private Sub ClearTextBoxes()
        tbxProperty01.Text = ""
        tbxProperty02.Text = ""
        tbxProperty03.Text = ""
        tbxProperty04.Text = ""
        tbxProperty05.Text = ""
        tbxProperty06.Text = ""
        tbxProperty07.Text = ""
        tbxProperty08.Text = ""
        tbxProperty09.Text = ""
        tbxProperty10.Text = ""
        tbxProperty11.Text = ""
        tbxProperty12.Text = ""
        tbxProperty13.Text = ""
        tbxProperty14.Text = ""
        tbxProperty15.Text = ""
        tbxProperty16.Text = ""
        tbxProperty17.Text = ""
        tbxProperty18.Text = ""
        tbxProperty19.Text = ""
        tbxProperty20.Text = ""
        tbxProperty21.Text = ""
        tbxProperty22.Text = ""
        tbxProperty23.Text = ""
        tbxProperty24.Text = ""
        tbxProperty25.Text = ""
        tbxProperty26.Text = ""
        tbxProperty27.Text = ""
        tbxProperty28.Text = ""
        tbxProperty29.Text = ""
        tbxProperty30.Text = ""
    End Sub

    Private Sub ClearPropertyVariables()
        prop01 = ""
        prop02 = ""
        prop03 = ""
        prop04 = ""
        prop05 = ""
        prop06 = ""
        prop07 = ""
        prop08 = ""
        prop09 = ""
        prop10 = ""
        prop11 = ""
        prop12 = ""
        prop13 = ""
        prop14 = ""
        prop15 = ""
        prop16 = ""
        prop17 = ""
        prop18 = ""
        prop19 = ""
        prop20 = ""
        prop21 = ""
        prop22 = ""
        prop23 = ""
        prop24 = ""
        prop25 = ""
        prop26 = ""
        prop27 = ""
        prop28 = ""
        prop29 = ""
        prop30 = ""

    End Sub

    Private Sub btnClearPropertyList_Click(sender As System.Object, e As System.EventArgs) Handles btnClearPropertyList.Click
        Call ClearLabels()
        Call ClearTextBoxes()
        Call ClearPropertyVariables()
    End Sub


    Private Sub btnComplexMenu_Click(sender As System.Object, e As System.EventArgs) Handles btnComplexMenu.Click
        ComplexProperties.Show()
    End Sub

    Private Sub cbxPDF_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles cbxPDF.CheckedChanged
        If cbxPDF.Checked = True Then
            chgPDF = "Yes"
        End If
        If cbxPDF.Checked = False Then
            chgPDF = "No"
        End If

        Dim objWriter As New System.IO.StreamWriter(checkboxData, False)
        objWriter.WriteLine(chgPDF)
        objWriter.WriteLine(runOnOp)
        objWriter.Close()

    End Sub

    Private Sub ReadCheckBoxes()
        Dim objReader As New System.IO.StreamReader(GlobalVariables.checkboxData)
        Dim r As Integer
        r = 1
        Dim chkLine As String
        If System.IO.File.Exists(checkboxData) = True Then
            Do While objReader.Peek() <> -1
                chkLine = objReader.ReadLine()
                If chkLine = "" Then
                    Exit Do
                End If
                If r = 1 Then
                    GlobalVariables.chgPDF = chkLine
                End If
                If r = 2 Then
                    GlobalVariables.runOnOp = chkLine
                End If
                r = r + 1
            Loop
            objReader.Close()
        Else
            System.IO.File.Create("C:\Restran Conversion\ComplexData.txt").Close()
            GlobalVariables.chgPDF = "No"
            GlobalVariables.runOnOp = "No"
        End If

    End Sub



    Private Sub btnExit_Click(sender As System.Object, e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
End Class

When they said they wanted the code, I dont think they meant all 1422 lines of it. This error could be caused because the designer code references a gui control that probalby was removed. I experienced something similar when using visual studio and writing in c#. Did you delete any gui control that had a method that it called?

I've changed the Option Restrict to "On". Here's the first error I'm having trouble resolving:

Error 1 Option Strict On requires all Function, Property, and Operator declarations to have an 'As' clause.

Here's the code that goes with that line:

 Public Function getFolderNameGD(ByVal fullyQualifiedFolderName As String, ByVal searchPattern As String)
        'return directory that matches searchPattern
        For Each fqDirName As String In System.IO.Directory.GetDirectories(fullyQualifiedFolderName, searchPattern, System.IO.SearchOption.TopDirectoryOnly)
            Return fqDirName
        Next
        Return String.Empty
    End Function

It doesn't seem to like "getFolderNameGD". The lines that go with this function now have been changed from

foldernameGD = getFolderNameGD("O:\Revenue Management\Centralized Revenue Management Service\CRMS Hotels", propertyNo2 & "*")

To this:

foldernameGD = CStr(getFolderNameGD("O:\Revenue Management\Centralized Revenue Management Service\CRMS Hotels", propertyNo2 & "*"))

Is it trying to tell me my Function name should change? If not, what is it?

You really need to learn how to initialise your variables. You need an As and an intial value like:
dim num as integer= 0 or dim str as string= " "
If it is areference type you need to use the New keyword as in:
Dim bottomLabel As New System.Windows.Forms.Label
Here is a good reference to start you off:
https://msdn.microsoft.com/en-us/library/7ee5a7s1.aspx
In your case I think it just means that you have to put the as clause at the enf of your function like:
Public Function getFolderNameGD(ByVal fullyQualifiedFolderName As String, ByVal searchPattern As String) As String

Edited 1 Year Ago by Minimalist

"In your case I think it just means that you have to put the as clause at the enf of your function like:
Public Function getFolderNameGD(ByVal fullyQualifiedFolderName As String, ByVal searchPattern As String) As String"

I didn't realize that you can (and in this case, should) do something like this. I've used the original syntax before with no issues.

Group, I've cleaned up all my errors. Unfortunately I'm still getting my error message. I'm wondering now.... Did I delete a GUI control as Toby_2 suggested? I don't recall doing this. But is there way I can find it?

I have a few unrelated suggestions.

You might want to replace the multiple declarations of prop## with

Private prop(30)

This would allow you to replace

prop01 = tbxProperty01.Text
lblProperty01.Text = prop01
prop02 = tbxProperty02.Text
lblProperty02.Text = prop02
prop03 = tbxProperty03.Text
lblProperty03.Text = prop03
prop04 = tbxProperty04.Text
lblProperty04.Text = prop04
prop05 = tbxProperty05.Text
lblProperty05.Text = prop05
prop06 = tbxProperty06.Text
lblProperty06.Text = prop06
prop07 = tbxProperty07.Text
lblProperty07.Text = prop07
prop08 = tbxProperty08.Text
lblProperty08.Text = prop08
prop09 = tbxProperty09.Text
lblProperty09.Text = prop09
prop10 = tbxProperty10.Text
lblProperty10.Text = prop10
prop11 = tbxProperty11.Text
lblProperty11.Text = prop11
prop12 = tbxProperty12.Text
lblProperty12.Text = prop12
prop13 = tbxProperty13.Text
lblProperty13.Text = prop13
prop14 = tbxProperty14.Text
lblProperty14.Text = prop14
prop15 = tbxProperty15.Text
lblProperty15.Text = prop15
prop16 = tbxProperty16.Text
lblProperty16.Text = prop16
prop17 = tbxProperty17.Text
lblProperty17.Text = prop17
prop18 = tbxProperty18.Text
lblProperty18.Text = prop18
prop19 = tbxProperty19.Text
lblProperty19.Text = prop19
prop20 = tbxProperty20.Text
lblProperty20.Text = prop20
prop01 = tbxProperty01.Text
lblProperty21.Text = prop21
prop22 = tbxProperty22.Text
lblProperty22.Text = prop22
prop23 = tbxProperty23.Text
lblProperty23.Text = prop23
prop24 = tbxProperty24.Text
lblProperty24.Text = prop24
prop25 = tbxProperty25.Text
lblProperty25.Text = prop25
prop26 = tbxProperty26.Text
lblProperty26.Text = prop26
prop27 = tbxProperty27.Text
lblProperty27.Text = prop27
prop28 = tbxProperty28.Text
lblProperty28.Text = prop28
prop29 = tbxProperty29.Text
lblProperty29.Text = prop29
prop30 = tbxProperty30.Text
lblProperty30.Text = prop30

with

For i As Integer = 1 To 30
    Dim seq As String = i.ToString("D2")
    Dim tbx As TextBox = Me.Controls("tbxProperty" & seq)
    Dim lbl As Label = Me.Controls("lblProperty" & seq)
    prop(i) = tbx.Text
    lbl.Text = prop(i)
Next

or, if you don't need prop() you could use.

For i As Integer = 1 To 30
    Dim seq As String = i.ToString("D2")
    Dim tbx As TextBox = Me.Controls("tbxProperty" & seq)
    Dim lbl As Label = Me.Controls("lblProperty" & seq)
    lbl.Text = tbx.Text
Next

Doing this shortens your code by several hundred lines and eliminates typos like the one at

prop20 = tbxProperty20.Text
lblProperty20.Text = prop20
prop01 = tbxProperty01.Text
lblProperty21.Text = prop21
prop22 = tbxProperty22.Text
lblProperty22.Text = prop22

where you coded prop01 instead of prop21

You could create two arrays like

Const ROOT As String = "C:\Restran Conversion\"

Private RequiredFolders() As String = {"Allover",
                                       "Restran",
                                       "DASRPT"}

Private RequiredFiles() As String = {"ComplexData.txt",
                                     "RestranFileConversion.txt",
                                     "cbxdata.txt"}

Then you could create the folders and files in a loop like

For Each folder As String In RequiredFolders
    'concatenate ROOT to folder to make the fully qualified path
Next

For Each file As String In RequiredFiles
    ...
Next

Structures like

If cplxprp = 1 Then
    ...
End If

If cplxprp = 2 Then
    ...
End If

If cplxprp = 3 Then
    ...
End If

are discouraged because only one (at most) will ever be true but all must be executed. Instead you should use

Select Case cplxprp
    Case 1
        ...
    Case 2
        ...
    Case 3
        ...
End Select

You can also add a

    Case Else
        ...

to handle the "none of the above" cases. There are several places where this would shorten and simplify your code.

Comments
Exellent advice.

Could you give us an example of what your foldername looks because I think you got something wrong in the get...

Rev Jim, thanks for the suggestions! These are absolutely fantastic. I knew there had to be a way to shorten the way it was written. I suspect it will be faster as well.

Minimalist, I'm not having any issue with the foldernames portion of this. It's finding everything correctly and working fine there. To get an idea of folder names, they look like this:

0208 - FPbS Norwood
0033-Sheraton Baltimore North Hotel
868-Sheraton Mahwah Hotel

To my initial issue, does any thing within this error message indicate where my problem is:

System.NullReferenceException: Object reference not set to an instance of an object.
at IPSDataUpdate.Main.RunComplexProperties()
at IPSDataUpdate.Main.Main_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

"Object Reference not set to an instance of an object." That suggests to me that I have some code in there that is pointing to an object that doesn't exist. Is my thinking right? If that's the case, wouldn't I get the squiggly lines in the code that would show me where my issue is?

Any thoughts and ideas?

Thanks, group! You're the best!

Don

To find the line that throws the exception try the following:
On the menu bar in visual basic:
1) Click on the 'Debug' menu item
2) Click 'Exceptions...'
3) Select 'Common Language Runtime Exceptions' - 'Thrown'
This should stop the program at the line the exception is thrown in.

Attachments Debug.jpg 24.62 KB

Minimalist,

Bingo! Found it!

strLength = propertyNo.Length

This is happening because I'm getting a "Null" value. The error message says, "NullReference exception occured".

I'm fairly sure I know why it's happening. And it is something that can happen. This specific line is looking for the number of characters in the property number. However it is possible for the variable to be blank (thus the "null" value). Now the question is, how do I overcome this "error".

Thanks again! You're the man!!

Don

Minimalist, never mind. I believe I've fixed it. I've written the following in:

If propertyNo IsNot Nothing Then
                strLength = propertyNo.Length
                Blah.. blah.. blah...
End If

I've tested it and it worked fine.

You're my hero!

Don

This question has already been answered. Start a new discussion instead.