none
Object invoked has disconnected from its clients ERROR

    Question

  • Hi everyone.. Im working on a VB6 migration to .Net and Im getting a very strange error. Heres part of the code im executing and where the error is thrown..

    I got a form where a message is shown in screen for the user to track what operations the main applications is running.. the routine is in my VB99_loadingScreen.

    VB99_LoadingScreen.DefInstance.Message("Reading Tag Configuration for Smart Devices")

    My form has the next routine where the message is shown. I use doevents to keep other part of code executing...

    Public Sub Message(ByVal sMessage As String)
          If Visible Then
              lblMessage.Text = sMessage
              pbProgress.ControlDefault = pbProgress.ControlDefault + 1
              System.Windows.Forms.Application.DoEvents()
          End If
    End Sub

    Now, before getting to this point, I show different messages with no problem at all. I dont get any errors.. but when I get to the system...doEvents, I get the error "the object invoked has disconnected from its clients". I debugged all my app and haven't found any errors at all. Im working with an OPC client, but no disconnections are being raised, no controls are being disposed no database operations are running... its pretty hard to understand without the rest of the code.. but what I do is show a message on a form in a label with progress bar (as you can see on Sub Message). Have no clue what this is happening...

    PLease help!!
    Thanks every1 =)

     

    Tuesday, April 18, 2006 10:02 PM

All replies

  • This looks like another threading issue with default instances in Visual Basic.  Do you have some more code you can provide to help me diagnose the issue?

    I'm assuming that whatever you are doing is executing asynchronously and when the execution reaches a certain stage, you are calling the Message method -- or using it as a handler or a delegate.  If you can provide more context, I might be able to help you. In the mean time, please look at:

    http://blogs.msdn.com/tobint/archive/2006/04/11/573772.aspx

    Let me know if that helps you at all.

    Wednesday, April 19, 2006 5:22 AM
  • Hey Tobin, thanks a bunch for you help..
    Sure I have code.. I still keep VB6 references, haven't spend time on changing them to .Net since what Im looking for first its getting the application running.. I will later work on trying to leave eveything in .Net.. This is all the complete routine.. I have references to other forms and to a DLL i created myself to save some time.. To give you more info.. this part of the code executes well the first time.. and no errors at all. Then in the main form, I got a reset button (you can say that) that loads eveything again (form controls, disconnection and connection from OPC server, etc..) and thats when the error appears. I've been tracking the error, cant find why the error is thrown in the system..doevents(), but I commented the line and some lines later the error appeared again, but this time it did make sense to me since my opcserver state was different from connected, but cant explain why is thrown if everything is exectued again.. Anyway If you need anything else, just say it.. Thanks for your time...

    Public Sub Get_Config_Data()
            Dim iStatus As Integer
            Dim sMessage As String
            Dim i As Short

            Dim vTagInfo As Object
            Dim TagCarrierArrive As String
            Dim bData As Boolean
            Dim bDataAsync As Boolean
            Dim bDataECrate As Boolean

            On Error GoTo ConfigError

            iStationStatus = -1
            bWorkInstAlreadyLoaded = False
            bPrevWorkInstAlreadyLoaded = False
            bStopProgramForSerno = False
            bCarrierPresent = False


            VB02_Work_Instructor.DefInstance.lblStartTime.Text = Format(Now, "MMM-DD HH:MM")

            VB99_Polling.DefInstance.tmrPrevProduct.Enabled = False
            VB99_Polling.DefInstance.SetPollingTimer(False)

            TagStatus.sName = ""
            TagStatus.sNode = ""
            TagStatus.sServer = ""

            VB99_LoadingScreen.DefInstance.pbProgress.ControlDefault = 1
            VB99_LoadingScreen.DefInstance.Show()
            VB99_LoadingScreen.DefInstance.Message("Disconnecting OPC")

            'Assuring OPC disconnetcion in order to avoid connection errors
            VB02_Work_Instructor.DefInstance.OPC_PLC_Message.Disconnect(sRetCode, sRetMsg)
            VB99_OCX.DefInstance.OPC.Disconnect(sRetCode, sRetMsg)
            VB99_Polling.DefInstance.OPC_Polling.Disconnect(sRetCode, sRetMsg)
            VB99_LoadingScreen.DefInstance.Message("Loading data from the INI files")

            'Retrieving the Configuration Data from the ini files.
            VB99_OCX.DefInstance.TextIO.FOpen(sStationConfigFile, Scripting.IOMode.ForReading, sRetCode, sRetMsg)
            sGeneralAppPath = VB99_OCX.DefInstance.TextIO.GetParameter("GENERAL_PATH")
            If sGeneralAppPath = "" Then
                MsgBox("Configuration file is damaged or application path could not be found. / No esta configurado el directorio de la aplicación o el archivo de configuración esta dañado.")
                End
            End If

            sErrorImagePath = sGeneralAppPath & sErrorImageDirectory
            On Error Resume Next
            VB02_Work_Instructor.DefInstance.fleDrawings4.Path = sErrorImagePath
            If Err.Number <> 0 Then
                MsgBox("Configuration file is damaged or application path could not be found. / No esta configurado el directorio de la aplicación o el archivo de configuración esta dañado.")
                End
            End If
            On Error GoTo ConfigError

            ' Obtaining Station Number
            VB99_OCX.DefInstance.TextIO.FOpen(sStationConfigFile, Scripting.IOMode.ForReading, sRetCode, sRetMsg)
            sStationNum = VB99_OCX.DefInstance.TextIO.GetParameter("STATION")
            If sStationNum = "" Then
                ConfigurationError("ERRMSG_01")
            End If

            ' Obtaining Production Line
            VB99_OCX.DefInstance.TextIO.FOpen(sStationConfigFile, Scripting.IOMode.ForReading, sRetCode, sRetMsg)
            sLineID = VB99_OCX.DefInstance.TextIO.GetParameter("LINE_ID")
            If sLineID = "" Then
                ConfigurationError("ERRMSG_02")
            End If

            VB99_OCX.DefInstance.TextIO.FOpen(sStationConfigFile, Scripting.IOMode.ForReading, sRetCode, sRetMsg)
            bLocalOPCServer = VB99_OCX.DefInstance.TextIO.GetParameter("REMOTE") <> "Y"

            ' Obtaining Parameters for DataBase connection
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sUserName = VB99_OCX.DefInstance.TextIO.GetParameter("DB_USER")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sPassword = VB99_OCX.DefInstance.TextIO.GetParameter("DB_PASSWORD")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sString = VB99_OCX.DefInstance.TextIO.GetParameter("DB_STRING")

            If sUserName = "" Or sPassword = "" Or sString = "" Then
                ConfigurationError("ERRMSG_03")
            End If

            VB99_LoadingScreen.DefInstance.Message("Connecting to DataBase: " & sString & "/" & sUserName)
            ' Connecting to DataBase
            VB99_OCX.DefInstance.DB.Disconnect(sRetCode, sRetMsg)
            VB99_OCX.DefInstance.DB.Settings(sUserName, sPassword, sString)
            VB99_OCX.DefInstance.DB.Connect(sRetCode, sRetMsg)

            If sRetCode <> "S" Then
                ConfigurationError("ERRMSG_04")
            End If

            ' data station for twin stations
            dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT data_station FROM process_station WHERE station_number = '" & sStationNum & "'", sRetCode, sRetMsg)
            If dbRS.Tables("SEL").Rows.Count > 0 Then
                For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                    sDataStationNum = VB99_OCX.DefInstance.DB.NVL(row("data_station"), sStationNum)
                Next
            End If
            dbRS.Tables.Remove("SEL")

            ' Load WI LayOut
            VB99_LoadingScreen.DefInstance.Message("Loading Work Instructor LayOut")
            LoadScreenLayout()
            VB02_Work_Instructor.DefInstance.ClearScreen()

            ' Reading Labels
            VB99_LoadingScreen.DefInstance.Message("Loading labels")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)

            VB02_Work_Instructor.DefInstance.lblTQC.Text = VB99_OCX.DefInstance.TextIO.GetParameter("BUTTON_MAIN_TQC").ToString
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            VB02_Work_Instructor.DefInstance.lblWork.Text = VB99_OCX.DefInstance.TextIO.GetParameter("BUTTON_MAIN_WORK")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            VB02_Work_Instructor.DefInstance.lblVerify.Text = VB99_OCX.DefInstance.TextIO.GetParameter("BUTTON_MAIN_VERIFY")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            VB02_Work_Instructor.DefInstance.lblNoCarrier.Text = VB99_OCX.DefInstance.TextIO.GetParameter("BUTTON_MAIN_NO_CARRIER")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            VB02_Work_Instructor.DefInstance.lblManual.Text = VB99_OCX.DefInstance.TextIO.GetParameter("BUTTON_MAIN_MANUAL")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            VB02_Work_Instructor.DefInstance.lblComplete.Text = VB99_OCX.DefInstance.TextIO.GetParameter("BUTTON_MAIN_COMPLETE_PROCCES")

            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sWI_MSG_NextProduct = VB99_OCX.DefInstance.TextIO.GetParameter("MSG_MAIN_NEXT_PRODUCT")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sWI_MSG_NoWork = VB99_OCX.DefInstance.TextIO.GetParameter("MSG_MAIN_NO_WORK")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sWI_MSG_Carrier = VB99_OCX.DefInstance.TextIO.GetParameter("MSG_MAIN_CARRIER")


            ' Reading Product List Configuration
            VB99_LoadingScreen.DefInstance.Message("Reading Product List Configuration")
            LoadPartListConfiguration()
            bPartListVisible = True
            TogglePartList()

            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sLstCmdUp1 = VB99_OCX.DefInstance.TextIO.GetParameter("LIST_PGUP1")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sLstCmdUp2 = VB99_OCX.DefInstance.TextIO.GetParameter("LIST_PGUP2")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sLstCmdDwn1 = VB99_OCX.DefInstance.TextIO.GetParameter("LIST_PGDOWN1")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sLstCmdDwn2 = VB99_OCX.DefInstance.TextIO.GetParameter("LIST_PGDOWN2")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sCompleteScn1 = VB99_OCX.DefInstance.TextIO.GetParameter("COMPLETE_PRODUCT1")
            VB99_OCX.DefInstance.TextIO.FOpen(sGeneralAppPath & sGeneralConfigFile, Scripting.IOMode.ForReading)
            sCompleteScn2 = VB99_OCX.DefInstance.TextIO.GetParameter("COMPLETE_PRODUCT2")
            VB99_OCX.DefInstance.TextIO.FClose(sRetCode, sRetMsg)

            'Open log file
            dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1 FROM station_configuration WHERE parameter_name = 'LogFilePath' AND station_number = '" & sStationNum & "' ORDER BY parameter_seqno", sRetCode, sRetMsg)
            If dbRS.Tables("SEL").Rows.Count > 0 Then
                For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                    bLogFile = True
                    sLogFile = logfilename(sStationNum)
                    sPathLogFile = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                    If Not VB99_OCX.DefInstance.TextIO.FileExists(sPathLogFile & sLogFile) Then
                        VB99_OCX.DefInstance.TextIO.FOpen(sPathLogFile & sLogFile, Scripting.IOMode.ForWriting)
                        VB99_OCX.DefInstance.TextIO.FClose(sPathLogFile & sLogFile)
                    End If
                Next
            Else
                bLogFile = False
            End If
            dbRS.Tables.Remove("SEL")

            ' Gets Station Type (PC Type, have Panel or not, etc)
            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "WI_StationType", 1, sWIStationType, sUsesOperationNumber, System.DBNull.Value.ToString, System.DBNull.Value.ToString, System.DBNull.Value.ToString, sRetCode, sRetMsg)
            If sWIStationType = "" Or sRetCode <> "S" Then
                ConfigurationError("ERRMSG_05")
            End If
            bCompleteButton = Mid(sUsesOperationNumber, 3, 1) = "Y"
            sUsesOperationNumber = Mid(sUsesOperationNumber, 1, 1)

            ' NOWORK Operations Configuration
            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "WI_ShowNOWORKOperations", 1, ShowNOWORKOperation.sShowNOWORK, ShowNOWORKOperation.sChangeOrder, , , , sRetCode, sRetMsg)
            If ShowNOWORKOperation.sShowNOWORK = "N" Then
                ShowNOWORKOperation.sWhere = " AND display_text <> 'NOWORK' "
            Else
                ShowNOWORKOperation.sWhere = " "
            End If
            If ShowNOWORKOperation.sChangeOrder = "Y" Then
                ShowNOWORKOperation.sOrderBy = " decode(display_text, 'NOWORK', 1, 0), "
            Else
                ShowNOWORKOperation.sOrderBy = " "
            End If

            If bCompleteButton Then
                VB02_Work_Instructor.DefInstance.imgComplete1.Visible = True
                VB02_Work_Instructor.DefInstance.lblComplete.Visible = True
                VB02_Work_Instructor.DefInstance.lblComplete.Enabled = True
                If sLayoutName = "STANDARD_1024" Then
                    VB02_Work_Instructor.DefInstance.lblComplete.Left = 627
                End If

            End If

            If sUsesOperationNumber <> "Y" Then
                bUsesOperationNumber = False
                VB02_Work_Instructor.DefInstance.lstOperations.Visible = False
                VB02_Work_Instructor.DefInstance.cmdOperationsPage0.Visible = False
                VB02_Work_Instructor.DefInstance.cmdOperationsPage1.Visible = False

                VB02_Work_Instructor.DefInstance.imgDrawingI.Top = 17
                VB02_Work_Instructor.DefInstance.imgDrawingI.Left = 468
                VB02_Work_Instructor.DefInstance.imgDrawingI.Width = 540
                VB02_Work_Instructor.DefInstance.imgDrawingI.Height = 712
            Else
                bUsesOperationNumber = True
            End If

            VB99_LoadingScreen.DefInstance.Message("Retrieving Station Information: " & sStationNum)
            ' Retrieving Station Information
            dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT plant_area, process_station.process_name process_name, substation_ind, subline_start_ind, previous_station, takt_time FROM process_station, manufacturing_process WHERE process_station.process_name = manufacturing_process.process_name AND station_number = '" & sStationNum & "'")
            If dbRS.Tables("SEL").Rows.Count < 0 Then
                ConfigurationError("ERRMSG_06")
            Else
                For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                    sPlantArea = VB99_OCX.DefInstance.DB.NVL(ROW("plant_area"), "")
                    sPrevStationNum = VB99_OCX.DefInstance.DB.NVL(ROW("previous_station"), "")
                    If ROW("substation_ind") = "Y" Then
                        bSubStationInd = True
                    Else
                        bSubStationInd = False
                    End If
                    If ROW("subline_start_ind") = "Y" Then
                        bSubLineStartInd = True
                    Else
                        bSubLineStartInd = False
                    End If
                    iStationTaktTime = CType(VB99_OCX.DefInstance.DB.NVL(ROW("takt_time"), 0), Short)
                    If iStationTaktTime <> 0 Then
                        VB02_Work_Instructor.DefInstance.pbarTaktTime.Max = iStationTaktTime
                    Else
                        VB02_Work_Instructor.DefInstance.txtTaktTime.Text = ""
                    End If
                    VB02_Work_Instructor.DefInstance.lblProcessName0.Text = ROW("process_name")
                    'VB02_Work_Instructor.DefInstance.lblProcessName1.Text = ROW("process_name")

                    'VB02_Work_Instructor.DefInstance.lblStationNumber0.Text = sStationNum
                    VB02_Work_Instructor.DefInstance.lblStationNumber1.Text = sStationNum
                    Shadow(VB02_Work_Instructor.DefInstance, VB02_Work_Instructor.DefInstance.lblStationNumber1)
                    Shadow(VB02_Work_Instructor.DefInstance, VB02_Work_Instructor.DefInstance.lblProcessName0)
                Next
            End If
            dbRS.Tables.Remove("SEL")

            'Retrieving the Configuration Data from the Data Base.
            sAcrobat_Path = VB99_OCX.DefInstance.DB.GetStationParameter(sStationNum, "Acrobat_Path", CStr(1), sRetCode, sRetMsg)
            If sRetCode <> "S" Then
                ConfigurationError("ERRMSG_30")
            End If
            sDefaultTQCStep = VB99_OCX.DefInstance.DB.GetStationParameter(sStationNum, "WI_DefaultTQCStep", CStr(1), sRetCode, sRetMsg)
            If sDefaultTQCStep = "" Then
                sDefaultTQCStep = CStr(1)
            End If

            sProductSeqnoLen = VB99_OCX.DefInstance.DB.GetSystemParameter("99", "PRODUCT_SEQNO_LEN")
            If sProductSeqnoLen = "" Then
                sProductSeqnoLen = CStr(11)
            End If

            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "TQC_BUTTONS_ENABLED", 1, sTQCButtonsEnabled(1), sTQCButtonsEnabled(2), sTQCButtonsEnabled(3), sTQCButtonsEnabled(4), sTQCButtonsEnabled(5), sRetCode, sRetMsg)
            VB02_Work_Instructor.DefInstance.imgTQCButtons1.Enabled = sTQCButtonsEnabled(1) = "Y"
            VB02_Work_Instructor.DefInstance.imgTQCButtons2.Enabled = sTQCButtonsEnabled(2) = "Y"
            VB02_Work_Instructor.DefInstance.imgTQCButtons3.Enabled = sTQCButtonsEnabled(3) = "Y"
            VB02_Work_Instructor.DefInstance.imgTQCButtons0.Enabled = sTQCButtonsEnabled(4) = "Y"
            VB02_Work_Instructor.DefInstance.imgTQCButtons4.Enabled = sTQCButtonsEnabled(5) = "Y"

            ' Log in Screen
            ApplicationLogIn()

            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "DrawingsPath", 1, sImgDrawingPath, sImgDrawingPathCache, sImgDrawingPathUsesFolder, "", "", sRetCode, sRetMsg)
            If sRetCode <> "S" Then
                ConfigurationError("ERRMSG_09")
            End If

            VB02_Work_Instructor.DefInstance.fleDrawings1.Path = sImgDrawingPath
            VB02_Work_Instructor.DefInstance.fleDrawings2.Path = sImgDrawingPath
            VB02_Work_Instructor.DefInstance.fleDrawings3.Path = sImgDrawingPath

            sDaysForRemark = VB99_OCX.DefInstance.DB.GetSystemParameter(sLineID, "DAYS_FOR_REMARK", sRetCode, sRetMsg)
            If sDaysForRemark = "" Then
                iDaysForRemark = 0
            Else
                iDaysForRemark = CShort(sDaysForRemark)
            End If

            bShowRejectNoWorkMessages = VB99_OCX.DefInstance.DB.GetStationParameter(sStationNum, "SHOW_REJECT_NOWORK_MESSAGES", CStr(1), sRetCode, sRetMsg) = "Y"

            sTaktTimeWarningTemp = VB99_OCX.DefInstance.DB.GetSystemParameter(sLineID, "TAKTTIME_WARNING", sRetCode, sRetMsg)
            If sTaktTimeWarningTemp = "" Then
                sTaktTimeWarning = 0.8
            Else
                sTaktTimeWarning = CSng(sTaktTimeWarningTemp)
            End If

            VB99_LoadingScreen.DefInstance.Message("Loading ScreenSaver Images and Menu Buttons")
            LoadScreenSaverImages()

            sStationAlreadyTriggered = VB99_OCX.DefInstance.DB.GetStationParameter(sStationNum, "ChkIfStationAlreadyTriggered", CStr(1))
            bChkIfStationAlreadyTriggered = sStationAlreadyTriggered <> ""


            ' Reading the configuration for Menu Buttons
            For i = 0 To iMenuButtonsCount - 1
                MenuButtons(i).sTitle = ""
                MenuButtons(i).sSubName = ""
                MenuButtons(i).sOptionalParam1 = ""
                MenuButtons(i).sOptionalParam2 = ""
                MenuButtons(i).sOptionalParam3 = ""
            Next

            VB02_Work_Instructor.DefInstance.lblMenuButtons0.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons1.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons2.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons3.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons4.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons5.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons6.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons7.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons8.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons9.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons10.Text = ""
            VB02_Work_Instructor.DefInstance.lblMenuButtons11.Text = ""

            dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT count('x') total FROM station_configuration WHERE parameter_name = 'WI_ButtonsConfig' AND station_number = '" & sStationNum & "'", sRetCode, sRetMsg)
            If dbRS.Tables("SEL").Rows.Count > 0 Then
                For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                    iTotalMenuButtons = row("TOTAL")
                Next
            End If
            dbRS.Tables.Remove("SEL")

            If iTotalMenuButtons = iMenuButtonsCount Then
                dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1, parameter_value2 , parameter_value3, parameter_value4, parameter_value5 FROM station_configuration WHERE parameter_name = 'WI_ButtonsConfig' AND station_number = '" & sStationNum & "' ORDER BY parameter_seqno", sRetCode, sRetMsg)
                i = 0
                If dbRS.Tables("SEL").Rows.Count > 0 Then
                    For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                        Select Case i
                            Case 0
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons0.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons0.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons0.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons0.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons0.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons0.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons0.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons0.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons0.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons0.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons0.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons0.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons0.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons0.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons0.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons0.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons0.Text = MenuButtons(i).sTitle
                                End If
                            Case 1
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons1.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons1.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons1.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons1.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons1.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons1.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons1.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons1.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons1.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons1.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons1.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons1.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons1.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons1.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons1.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons1.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons1.Text = MenuButtons(i).sTitle
                                End If
                            Case 2
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons2.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons2.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons2.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons2.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons2.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons2.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons2.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons2.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons2.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons2.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons2.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons2.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons2.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons2.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons2.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons2.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons2.Text = MenuButtons(i).sTitle
                                End If
                            Case 3
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons3.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons3.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons3.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons3.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons3.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons3.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons3.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons3.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons3.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons3.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons3.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons3.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons3.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons3.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons3.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons3.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons3.Text = MenuButtons(i).sTitle
                                End If
                            Case 4
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons4.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons4.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons4.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons4.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons4.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons4.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons4.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons4.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons4.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons4.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons4.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons4.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons4.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons4.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons4.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons4.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons4.Text = MenuButtons(i).sTitle
                                End If
                            Case 5
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons5.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons5.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons5.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons5.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons5.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons5.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons5.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons5.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons5.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons5.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons5.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons5.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons5.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons5.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons5.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons5.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons5.Text = MenuButtons(i).sTitle
                                End If
                            Case 6
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons6.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons6.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons6.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons6.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons6.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons6.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons6.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons6.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons6.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons6.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons6.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons6.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons6.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons6.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons6.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons6.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons6.Text = MenuButtons(i).sTitle
                                End If
                            Case 7
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons7.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons7.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons7.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons7.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons7.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons7.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons7.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons7.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons7.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons7.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons7.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons7.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons7.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons7.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons7.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons7.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons7.Text = MenuButtons(i).sTitle
                                End If
                            Case 8
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons8.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons8.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons8.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons8.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons8.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons8.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons8.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons8.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons8.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons8.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons8.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons8.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons8.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons8.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons8.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons8.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons8.Text = MenuButtons(i).sTitle
                                End If
                            Case 9
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons9.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons9.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons9.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons9.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons9.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons9.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons9.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons9.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons9.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons9.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons9.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons9.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons9.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons9.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons9.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons9.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons9.Text = MenuButtons(i).sTitle
                                End If
                            Case 10
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons10.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons10.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons10.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons10.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons10.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons10.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons10.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons10.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons10.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons10.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons10.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons10.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons10.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons10.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons10.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons10.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons10.Text = MenuButtons(i).sTitle
                                End If
                            Case 11
                                MenuButtons(i).sTitle = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                MenuButtons(i).sSubName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                MenuButtons(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                MenuButtons(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                MenuButtons(i).sOptionalParam3 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                If MenuButtons(i).sSubName = "" Then
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons11.Visible = False
                                    VB02_Work_Instructor.DefInstance.imgMenuButtons11.Enabled = False
                                Else
                                    If MenuButtons(i).sTitle = "." Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons11.Visible = False
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons11.Enabled = False
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons11.Visible = True
                                    End If

                                    VB02_Work_Instructor.DefInstance.imgMenuButtons11.Enabled = True

                                    If MenuButtons(i).sTitle.Length > 7 Then
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons11.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons11.Font, 9)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons11.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons11.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons11.Top = VB6.TwipsToPixelsY(751)
                                    Else
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons11.Font = VB6.FontChangeSize(VB02_Work_Instructor.DefInstance.lblMenuButtons11.Font, 11)
                                        VB02_Work_Instructor.DefInstance.lblMenuButtons11.Font = VB6.FontChangeBold(VB02_Work_Instructor.DefInstance.lblMenuButtons11.Font, True)
                                        If sLayoutName = "STANDARD_1024" Then VB02_Work_Instructor.DefInstance.lblMenuButtons11.Top = VB6.TwipsToPixelsY(749)
                                    End If
                                    VB02_Work_Instructor.DefInstance.lblMenuButtons11.Text = MenuButtons(i).sTitle
                                End If
                        End Select
                        i += 1
                    Next
                    dbRS.Tables.Remove("SEL")
                End If
            Else
                ConfigurationError("ERRMSG_31")
            End If

            VB99_LoadingScreen.DefInstance.Message("Reading Tag Configuration")
            'Reading Tag Configuration
            Select Case sWIStationType
                Case "MA250", "MA350", "PF_NO_PANEL"
                    VB99_Polling.DefInstance.tmpChkOPCConnection.Enabled = True
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_Status", 1, TagStatus.sName, TagStatus.sNode, TagStatus.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_11")
                    End If
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_PalletNumber", 1, TagPalleteNumber.sName, TagPalleteNumber.sNode, TagPalleteNumber.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_12")
                    End If
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes1", 1, TagStatusInWAmes1.sName, TagStatusInWAmes1.sNode, TagStatusInWAmes1.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_13")
                    End If
                Case "PLC_NO_CARRIER"
                    VB99_Polling.DefInstance.tmpChkOPCConnection.Enabled = True
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_Status", 1, TagStatus.sName, TagStatus.sNode, TagStatus.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_11")
                    End If
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes1", 1, TagStatusInWAmes1.sName, TagStatusInWAmes1.sNode, TagStatusInWAmes1.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_13")
                    End If
            End Select

            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_Message", 1, TagMessage.sName, TagMessage.sNode, TagMessage.sServer, "", "", sRetCode, sRetMsg)

            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "UnAssignCarrierSecondary", 1, TagCarrierArrive, TagCarrierNumber, TagAck, TagError, sPlantAreaParam, sRetCode, sRetMsg)

            'async.subassembly
            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "ASYNC_SUBASSEMBLY", 1, TagCarrierArriveAsync, TagCarrierNumberAsync, sPlantAreaParamAsync, TagCarrierNumberAsyncAck, TagAsyncError, sRetCode, sRetMsg)

            'e-crate validation
            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "E_CRATE_VALIDATION", 1, TagCreateAccept, TagCreateReject, TagCreatePresent, TagCreateSerno, "", sRetCode, sRetMsg)

            Select Case sWIStationType
                Case "MA250", "MA350"
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_TaktTime", 1, TagTaktTime.sName, TagTaktTime.sNode, TagTaktTime.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_14")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_SequenceNumber", 1, TagProductSeqno.sName, TagProductSeqno.sNode, TagProductSeqno.sServer, "", "", sRetCode, sRetMsg)

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_SerialNumber", 1, TagProductSerno.sName, TagProductSerno.sNode, TagProductSerno.sServer, "", "", sRetCode, sRetMsg)

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_RestartStation", 1, TagRestartStation.sName, TagRestartStation.sNode, TagRestartStation.sServer, "", "", sRetCode, sRetMsg)
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes0", 1, TagStatusInWAmes0.sName, TagStatusInWAmes0.sNode, TagStatusInWAmes0.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_18")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes2", 1, TagStatusInWAmes2.sName, TagStatusInWAmes2.sNode, TagStatusInWAmes2.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_19")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes3", 1, TagStatusInWAmes3.sName, TagStatusInWAmes3.sNode, TagStatusInWAmes3.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_20")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes4", 1, TagStatusInWAmes4.sName, TagStatusInWAmes4.sNode, TagStatusInWAmes4.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_21")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes5", 1, TagStatusInWAmes5.sName, TagStatusInWAmes5.sNode, TagStatusInWAmes5.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_22")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes6", 1, TagStatusInWAmes6.sName, TagStatusInWAmes6.sNode, TagStatusInWAmes6.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_23")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes7", 1, TagStatusInWAmes7.sName, TagStatusInWAmes7.sNode, TagStatusInWAmes7.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_24")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes8", 1, TagStatusInWAmes8.sName, TagStatusInWAmes8.sNode, TagStatusInWAmes8.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_26")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes9", 1, TagStatusInWAmes9.sName, TagStatusInWAmes9.sNode, TagStatusInWAmes9.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_32")
                    End If

                    'Checking if this station Reads the Timing Offset
                    If VB99_OCX.DefInstance.DB.GetStationParameter(sStationNum, "TimingOffset", CStr(1), sRetCode, sRetMsg) = "Y" Then
                        dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1, parameter_value2, parameter_value3, parameter_seqno FROM station_configuration WHERE parameter_name = 'Tag_TimingOffsetProduct_Seqno' AND station_number = '" & sStationNum & "' ORDER BY parameter_seqno", sRetCode, sRetMsg)
                        If dbRS.Tables("SEL").Rows.Count > 0 Then
                            For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                                TagTimingOffsetProductSeqno(ROW("parameter_seqno")).sName = ROW("parameter_value1")
                                If bLocalOPCServer Then
                                    TagTimingOffsetProductSeqno(ROW("parameter_seqno")).sNode = "LOCAL"
                                Else
                                    TagTimingOffsetProductSeqno(ROW("parameter_seqno")).sNode = ROW("parameter_value2")
                                End If

                                TagTimingOffsetProductSeqno(ROW("parameter_seqno")).sServer = ROW("parameter_value3")
                            Next
                        End If
                        dbRS.Tables.Remove("SEL")

                        dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1, parameter_value2, parameter_value3, parameter_seqno FROM station_configuration WHERE parameter_name = 'Tag_TimingOffsetValue' AND station_number = '" & sStationNum & "' ORDER BY parameter_seqno", sRetCode, sRetMsg)
                        If dbRS.Tables("SEL").Rows.Count > 0 Then
                            For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                                TagTimingOffsetValue(ROW("parameter_seqno")).sName = ROW("parameter_value1")
                                If bLocalOPCServer Then
                                    TagTimingOffsetValue(ROW("parameter_seqno")).sNode = "LOCAL"
                                Else
                                    TagTimingOffsetValue(ROW("parameter_seqno")).sNode = ROW("parameter_value2")
                                End If

                                TagTimingOffsetValue(ROW("parameter_seqno")).sServer = ROW("parameter_value3")
                            Next
                        End If
                        dbRS.Tables.Remove("SEL")
                    End If

                    If bLocalOPCServer Then
                        TagStatus.sNode = "LOCAL"
                        TagMessage.sNode = "LOCAL"
                        TagPalleteNumber.sNode = "LOCAL"
                        TagProductSeqno.sNode = "LOCAL"
                        TagProductSerno.sNode = "LOCAL"
                        TagTaktTime.sNode = "LOCAL"
                        TagStatusInWAmes0.sNode = "LOCAL"
                        TagStatusInWAmes1.sNode = "LOCAL"
                        TagStatusInWAmes2.sNode = "LOCAL"
                        TagStatusInWAmes3.sNode = "LOCAL"
                        TagStatusInWAmes4.sNode = "LOCAL"
                        TagStatusInWAmes5.sNode = "LOCAL"
                        TagStatusInWAmes6.sNode = "LOCAL"
                        TagStatusInWAmes7.sNode = "LOCAL"
                        VB99_OCX.DefInstance.OPC.Connect(TagStatus.sServer, "LOCAL", sRetCode, sRetMsg)
                        If sRetCode = "N" Then
                            ConfigurationError("ERRMSG_25")
                        End If
                    End If

                Case "PLC_NO_CARRIER"
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_SequenceNumber", 1, TagProductSeqno.sName, TagProductSeqno.sNode, TagProductSeqno.sServer, "", "", sRetCode, sRetMsg)

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_SerialNumber", 1, TagProductSerno.sName, TagProductSerno.sNode, TagProductSerno.sServer, "", "", sRetCode, sRetMsg)

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes0", 1, TagStatusInWAmes0.sName, TagStatusInWAmes0.sNode, TagStatusInWAmes0.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_18")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes6", 1, TagStatusInWAmes6.sName, TagStatusInWAmes6.sNode, TagStatusInWAmes6.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_23")
                    End If

                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_StatusInWAmes7", 1, TagStatusInWAmes7.sName, TagStatusInWAmes7.sNode, TagStatusInWAmes7.sServer, "", "", sRetCode, sRetMsg)
                    If sRetCode <> "S" Then
                        ConfigurationError("ERRMSG_24")
                    End If

                    'Checking if this station Reads the Timing Offset
                    If VB99_OCX.DefInstance.DB.GetStationParameter(sStationNum, "TimingOffset", CStr(1), sRetCode, sRetMsg) = "Y" Then
                        dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1, parameter_value2, parameter_value3, parameter_seqno FROM station_configuration WHERE parameter_name = 'Tag_TimingOffsetProduct_Seqno' AND station_number = '" & sStationNum & "' ORDER BY parameter_seqno", sRetCode, sRetMsg)
                        If dbRS.Tables("SEL").Rows.Count > 0 Then
                            For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                                TagTimingOffsetProductSeqno(ROW("parameter_seqno")).sName = ROW("parameter_value1")
                                If bLocalOPCServer Then
                                    TagTimingOffsetProductSeqno(ROW("parameter_seqno")).sNode = "LOCAL"
                                Else
                                    TagTimingOffsetProductSeqno(ROW("parameter_seqno")).sNode = ROW("parameter_value2")
                                End If

                                TagTimingOffsetProductSeqno(ROW("parameter_seqno")).sServer = ROW("parameter_value3")
                            Next
                        End If
                        dbRS.Tables.Remove("SEL")

                        dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1, parameter_value2, parameter_value3, parameter_seqno FROM station_configuration WHERE parameter_name = 'Tag_TimingOffsetValue' AND station_number = '" & sStationNum & "' ORDER BY parameter_seqno", sRetCode, sRetMsg)
                        If dbRS.Tables("SEL").Rows.Count > 0 Then
                            For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                                TagTimingOffsetValue(ROW("parameter_seqno")).sName = ROW("parameter_value1")
                                If bLocalOPCServer Then
                                    TagTimingOffsetValue(ROW("parameter_seqno")).sNode = "LOCAL"
                                Else
                                    TagTimingOffsetValue(ROW("parameter_seqno")).sNode = ROW("parameter_value2")
                                End If

                                TagTimingOffsetValue(ROW("parameter_seqno")).sServer = ROW("parameter_value3")
                            Next
                        End If
                        dbRS.Tables.Remove("SEL")
                    End If

                    If bLocalOPCServer Then
                        TagStatus.sNode = "LOCAL"
                        TagMessage.sNode = "LOCAL"
                        TagPalleteNumber.sNode = "LOCAL"
                        TagProductSeqno.sNode = "LOCAL"
                        TagProductSerno.sNode = "LOCAL"
                        TagTaktTime.sNode = "LOCAL"
                        TagStatusInWAmes0.sNode = "LOCAL"
                        TagStatusInWAmes1.sNode = "LOCAL"
                        TagStatusInWAmes2.sNode = "LOCAL"
                        TagStatusInWAmes3.sNode = "LOCAL"
                        TagStatusInWAmes4.sNode = "LOCAL"
                        TagStatusInWAmes5.sNode = "LOCAL"
                        TagStatusInWAmes6.sNode = "LOCAL"
                        TagStatusInWAmes7.sNode = "LOCAL"
                        VB99_OCX.DefInstance.OPC.Connect(TagStatus.sServer, "LOCAL", sRetCode, sRetMsg)
                        If sRetCode = "N" Then
                            ConfigurationError("ERRMSG_25")
                        End If
                    End If
            End Select

            'VB99_LoadingScreen.DefInstance.Message("Reading Tag Configuration for Smart Devices")
            Select Case sWIStationType
                Case "MA250", "MA350", "PF_NO_PANEL"
                    'Reading Tag Configuration for Number of Cylinders
                    VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "Tag_NumberOfCylinders", 1, TagNumberOfCylinders.sName, TagNumberOfCylinders.sNode, TagNumberOfCylinders.sServer, "", "", sRetCode, sRetMsg)
                    If bLocalOPCServer Then
                        TagNumberOfCylinders.sNode = "LOCAL"
                    End If
            End Select

            Select Case sWIStationType
                Case "MA250", "MA350", "NOPLC", "SCANNER", "PLC_NO_CARRIER"
                    'Reading Tag Configuration for Smart Devices
                    iTotalSmartDev = 0
                    dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT count(*) total_dev FROM station_configuration WHERE parameter_name = 'Tag_SmartDev' AND station_number = '" & sStationNum & "'", sRetCode, sRetMsg)
                    If dbRS.Tables("SEL").Rows.Count > 0 Then
                        For Each row As DataRow In dbRS.Tables("SEL").Rows
                            iTotalSmartDev = ROW("total_dev")
                        Next
                    End If
                    dbRS.Tables.Remove("SEL")

                    If iTotalSmartDev > 0 Then
                        ReDim TagSmartDevices(iTotalSmartDev)
                        dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1, parameter_value2, parameter_value3, parameter_value4 FROM station_configuration WHERE parameter_name = 'Tag_SmartDev' AND station_number = '" & sStationNum & "' ORDER BY parameter_seqno", sRetCode, sRetMsg)
                        i = 1
                        If dbRS.Tables("SEL").Rows.Count > 0 Then
                            For Each row As DataRow In dbRS.Tables("SEL").Rows
                                TagSmartDevices(i).sName = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value1"), "")
                                If bLocalOPCServer And VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "") = "OPC" Then
                                    TagSmartDevices(i).sNode = "LOCAL"
                                Else
                                    TagSmartDevices(i).sNode = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value2"), "")
                                End If
                                TagSmartDevices(i).sServer = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value3"), "")
                                TagSmartDevices(i).sCommType = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                i = i + 1
                            Next
                        End If
                        dbRS.Tables.Remove("SEL")
                    End If
            End Select

            Select Case sWIStationType
                Case "MA250", "MA350", "NOPLC", "SCANNER", "PF_NO_PANEL", "PLC_NO_CARRIER"
                    ' Reading the configuration for Dynamic Procedure calls (ExecProcessOnEvent)
                    iTotalDynamicSub = 0
                    dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT count('x') total_sub FROM station_configuration WHERE parameter_name = 'ExecProcessOnEvent' AND station_number = '" & sStationNum & "' AND parameter_value3 = 'Y'", sRetCode, sRetMsg)
                    If dbRS.Tables("SEL").Rows.Count > 0 Then
                        For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                            iTotalDynamicSub = ROW("total_sub")
                        Next
                        dbRS.Tables.Remove("SEL")
                    End If

                    If iTotalDynamicSub > 0 Then
                        ReDim DynamicSubs(iTotalDynamicSub - 1)
                        dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1, parameter_value2 , parameter_value4, parameter_value5 FROM station_configuration WHERE parameter_name = 'ExecProcessOnEvent' AND station_number = '" & sStationNum & "' AND parameter_value3 = 'Y' ORDER BY parameter_seqno", sRetCode, sRetMsg)
                        i = 0
                        If dbRS.Tables("SEL").Rows.Count > 0 Then
                            For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                                DynamicSubs(i).sSubName = ROW("parameter_value1")
                                DynamicSubs(i).sEvent = ROW("parameter_value2")
                                DynamicSubs(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                DynamicSubs(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                i = i + 1
                            Next
                        End If
                        dbRS.Tables.Remove("SEL")
                    End If

                    ' Reading the configuration for Dynamic Function calls (ExecFunctionOnEvent)
                    iTotalDynamicFunction = 0
                    dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT count('x') total_sub FROM station_configuration WHERE parameter_name = 'ExecFunctionOnEvent' AND station_number = '" & sStationNum & "' AND parameter_value3 = 'Y'", sRetCode, sRetMsg)
                    If dbRS.Tables("SEL").Rows.Count > 0 Then
                        For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                            iTotalDynamicFunction = ROW("total_sub")
                        Next
                    End If
                    dbRS.Tables.Remove("SEL")

                    If iTotalDynamicFunction > 0 Then
                        ReDim DynamicFunctions(iTotalDynamicFunction - 1)
                        dbRS = VB99_OCX.DefInstance.DB.dbSelect("SELECT parameter_value1, parameter_value2 , parameter_value4, parameter_value5 FROM station_configuration WHERE parameter_name = 'ExecFunctionOnEvent' AND station_number = '" & sStationNum & "' AND parameter_value3 = 'Y' ORDER BY parameter_seqno", sRetCode, sRetMsg)
                        i = 0
                        If dbRS.Tables("SEL").Rows.Count > 0 Then
                            For Each ROW As DataRow In dbRS.Tables("SEL").Rows
                                DynamicFunctions(i).sFunctionName = ROW("parameter_value1")
                                DynamicFunctions(i).sEvent = ROW("parameter_value2")
                                DynamicFunctions(i).sOptionalParam1 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value4"), "")
                                DynamicFunctions(i).sOptionalParam2 = VB99_OCX.DefInstance.DB.NVL(ROW("parameter_value5"), "")
                                i = i + 1
                            Next
                        End If
                        dbRS.Tables.Remove("SEL")
                    End If
            End Select

            Select Case sWIStationType
                Case "MA250", "MA350", "PF_NO_PANEL", "PLC_NO_CARRIER"
                    'VB99_LoadingScreen.DefInstance.Message("Connecting to OPC Server")
                Case "NOPLC"
                    VB99_LoadingScreen.DefInstance.Message("Start Polling Data Base")
                Case "SCANNER"
                    VB99_LoadingScreen.DefInstance.Message("Ready")
            End Select

            ' Connecting to the Message Tag
            If TagMessage.sServer <> "" Then
                VB02_Work_Instructor.DefInstance.OPC_PLC_Message.Connect(TagMessage.sServer, TagMessage.sNode, sRetCode, sRetMsg)

                If sRetCode = "N" Then
                    ConfigurationError("ERRMSG_25")
                End If

                sMessage = VB02_Work_Instructor.DefInstance.OPC_PLC_Message.OPC_Read(TagMessage.sName, sRetCode, sRetMsg)
                VB02_Work_Instructor.DefInstance.OPC_PLC_Message.UseEvents(True)
                'agregue .tostring y al final mande nothing
                VB02_Work_Instructor.DefInstance.OPC_PLC_Message_OPCDataChanged("", sMessage, 0)
            End If

            Select Case sWIStationType
                Case "MA250", "MA350", "PF_NO_PANEL", "PLC_NO_CARRIER"
                    ' Connecting to the Status Tag
                    VB99_Polling.DefInstance.OPC_Polling.Connect(TagStatus.sServer, TagStatus.sNode, sRetCode, sRetMsg)
                    If sRetCode = "N" Then
                        ConfigurationError("ERRMSG_25")
                    End If
                    iStatus = VB99_Polling.DefInstance.OPC_Polling.OPC_Read(TagStatus.sName, sRetCode, sRetMsg)
                    VB99_Polling.DefInstance.OPC_Polling.UseEvents(True)
                    'VB99_Polling.OPC_Polling_OPCDataChanged(VB99_Polling.OPC_Polling, New AxAmesComm.__OPC_OPCDataChangedEvent("", iStatus, 0))
                    VB99_Polling.DefInstance.OPC_Polling_OPCDataChanged("", iStatus, 0)
            End Select

            'split the info for event
            If TagCarrierArrive <> "" Then
                vTagInfo = Split(TagCarrierArrive, ",")
                TagCA.sServer = vTagInfo(0)
                TagCA.sNode = vTagInfo(1)
                TagCA.sName = vTagInfo(2)

                If TagCA.sServer <> "" Then
                    VB99_OCX.DefInstance.OPC_Event.Connect(TagCA.sServer, TagCA.sNode, sRetCode, sRetMsg)
                    If sRetCode = "N" Then
                        ConfigurationError("ERRMSG_25")
                    End If
                    bData = VB99_OCX.DefInstance.OPC_Event.OPC_Read(TagCA.sName, sRetCode, sRetMsg)
                    VB99_OCX.DefInstance.OPC_Event.UseEvents(True)
                    '                VB99_OCX.OPC_Event_OPCDataChanged(VB99_OCX.OPC_Event.ToString, New AxAmesComm.__OPC_OPCDataChangedEvent(TagCA.sName, bData, 0), 0)
                    VB99_OCX.DefInstance.OPC_Event_OPCDataChanged(TagCA.sName, bData, 0)
                End If
            End If

            'async.subassembly
            If TagCarrierArriveAsync <> "" Then
                vTagInfo = Split(TagCarrierArriveAsync, ",")
                TagCAAsync.sServer = vTagInfo(0)
                TagCAAsync.sNode = vTagInfo(1)
                TagCAAsync.sName = vTagInfo(2)
                If TagCAAsync.sServer <> "" Then
                    VB99_OCX.DefInstance.OPC_Event.Connect(TagCAAsync.sServer, TagCAAsync.sNode, sRetCode, sRetMsg)
                    If sRetCode = "N" Then
                        ConfigurationError("ERRMSG_25")
                    End If
                    bDataAsync = VB99_OCX.DefInstance.OPC_Event.OPC_Read(TagCAAsync.sName, sRetCode, sRetMsg)
                    VB99_OCX.DefInstance.OPC_Event.UseEvents(True)
                    'VB99_OCX.OPC_Event_OPCDataChanged(VB99_OCX.OPC_Event.ToString, New AxAmesComm.__OPC_OPCDataChangedEvent(TagCAAsync.sName, bDataAsync, 0), 0)
                    VB99_OCX.DefInstance.OPC_Event_OPCDataChanged(TagCAAsync.sName, bDataAsync, 0)
                End If
            End If

            'e-crate validation
            If TagCreatePresent <> "" Then
                vTagInfo = Split(TagCreatePresent, ",")
                TagECPresent.sServer = vTagInfo(0)
                TagECPresent.sNode = vTagInfo(1)
                TagECPresent.sName = vTagInfo(2)
                If TagECPresent.sServer <> "" Then
                    VB99_OCX.DefInstance.OPC_Event.Connect(TagECPresent.sServer, TagECPresent.sNode, sRetCode, sRetMsg)
                    If sRetCode = "N" Then
                        ConfigurationError("ERRMSG_25")
                    End If
                    bDataECrate = VB99_OCX.DefInstance.OPC_Event.OPC_Read(TagECPresent.sName, sRetCode, sRetMsg)
                    VB99_OCX.DefInstance.OPC_Event.UseEvents(True)
                    '                VB99_OCX.OPC_Event_OPCDataChanged(VB99_OCX.OPC_Event.ToString, New AxAmesComm.__OPC_OPCDataChangedEvent(TagECPresent.sName, bDataECrate, 0), 0)
                    VB99_OCX.DefInstance.OPC_Event_OPCDataChanged(TagECPresent.sName, bDataECrate, 0)
                End If
            End If

            Select Case sWIStationType
                Case "NOPLC"
                    sCheckBeforeCompletionStatus = VB99_OCX.DefInstance.DB.GetStationParameter(sStationNum, "CheckBeforeCompletion", CStr(1), sRetCode, sRetMsg)
                    VB99_Polling.DefInstance.tmpChkOPCConnection.Enabled = False
                    VB99_Polling.DefInstance.SetPollingTimer(True)
                Case Else
                    VB99_Polling.DefInstance.SetPollingTimer(False)
            End Select

            VB02_Work_Instructor.DefInstance.tmrProductSeqno.Enabled = True

            VB99_OCX.DefInstance.DB.GetAllStationParameters(sStationNum, "RealTime_Display", 1, sRealTimeEnabled, sRealTimeDisplay, sRealTimeRefresh, "", "", sRetCode, sRetMsg)
            If sRealTimeEnabled = "Y" Then
                VB02_Work_Instructor.DefInstance.tmrAndonBoard.Enabled = True
                VB02_Work_Instructor.DefInstance.tmrAndonBoard.Interval = CDbl(sRealTimeRefresh) * 1000
                VB02_Work_Instructor.DefInstance.tmrAndonBoard_Tick(VB02_Work_Instructor.DefInstance.tmrAndonBoard, New System.EventArgs)
            End If

            Select Case sWIStationType
                Case "SCANNER"
                    VB02_Work_Instructor.DefInstance.ShowDrawing(0, 0)
                    VB02_Work_Instructor.DefInstance.TopTab(0)
                    VB02_Work_Instructor.DefInstance.tmrScreenSaverPolling_Tick(VB02_Work_Instructor.DefInstance.tmrScreenSaverPolling, New System.EventArgs)
                    ShowScreenSaver()
                Case Else
            End Select

            VB99_LoadingScreen.DefInstance.Hide()

            Exit Sub

    ConfigError:
            If Err.Number = 727 Then
                On Error Resume Next
            End If
            If MsgBoxResult.Cancel = MsgBox("Error loading configuration information, Press OK to end, or Cancel to change station. / Error loading information Error cargando la configuración para la estación. Presione OK para terminar la aplicación. (Cancel para cambiar de estación)" & Chr(10) & Err.Description, MsgBoxStyle.OKCancel) Then
                ChangeStation()
            End If
            End
        End Sub

     

     

    Wednesday, April 19, 2006 3:24 PM
  • OK. Just a few more questions.

    #1 Did you enable the application framework in your application by any chance?  If so, check out the following article: http://support.microsoft.com/kb/906769/en-us

    #2 Is this application running on a multiprocessor box, by any chance? (Or a machine witha hyperthreaded or dual-core processor).

    I haven't had a chance to look through your code yet, but will make some more time tonight if we don't find any answers before hand.

     

    Wednesday, April 19, 2006 5:05 PM
  • Sup Titus...

    I've reviewed your blog and everything you talk about sounds really logic. I also read the support article. Im using VB 2003, so the "Enable application framework" option Im not sure where to find it and where to activate it. Not sure also if changing the code will work, but I'll give it a try.

    The application runs on a single processor mainly but it can be executed on different types. Here we have a bunch of different intel versions (Pentium 4 HT, P4, Pentium III and so on...)  Im working on a P4 HT in fact, where I'm making changes and testing everything I can.

    I still haven't been able to find the cause for my exception. Ive been working on it since 8 Am (4:43 PM overhere) I now see binaries, lol..

    Thanks Titus..

    Wednesday, April 19, 2006 9:46 PM
  • If you are using VS 2003, you will not have the option to enable the application framework.
    Wednesday, April 19, 2006 10:03 PM
  • Thats what I thought. In the mean time I'll continue with the tests, I'll analyzed again see what I can find. Thanks Titus..
    Thursday, April 20, 2006 9:16 PM
  • I researched your issue last night without any conclusions. I'm stil trying to reproduce the issue. I'll let you know once I find anything of use to you.
    Thursday, April 20, 2006 9:19 PM
  • Thanks Tobin..

    Ive trying to find the error cause and haven't still found anything. Is there a way to begin application again destroying the current thread? Cuz what Im doing on my app, is reload all the form (you can say) and connecting to database and read from file for control properties. The connections I have to database and to OPC are being reconnected, the error is thrown before arriving to this code but debuggin I do enter to OPC code and I got the line:

    MyGroup.OPCItems.Item(lIdx).Read(OPCAutomation.OPCDataSource.OPCDevice, vValue)

    So the first time it does read from the item correctly, when reloading this is where the error is launched.

    Thanks..

    JP

    Monday, April 24, 2006 3:21 PM
  • Sup tobin... got any news on my problem? I still havent been able to run it propertly.. =(

    Friday, May 05, 2006 1:08 PM