VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} PART_FORMULAEDIT 
   Caption         =   "Слагаемые формулы"
   ClientHeight    =   1905
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5685
   OleObjectBlob   =   "PART_FORMULAEDIT.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "PART_FORMULAEDIT"
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False





Option Explicit

Public pnRetArrayValue As Variant, pnRetArrayText As Variant, pnRetArrayLink As Variant, pnCount As Integer
Public pbMode As Boolean 'Режим загрузки
Public pcCodeStr As String ' Наименование строки
Public pcNameGraf As String 'Наименование графы
Public pcNamePage As String 'Наименование листа
Public pcZnak As String 'наименование знака
Public pnTypeFormula As Integer 'тип формулы
Public pnLinkStr As Integer 'LINK строки
Public pnNumGraf As Integer ' номер графы

Public Sub Form_init()
If pbMode Then ' Редактирование
    Me.TxtBar.value = pcCodeStr
    Me.TxtGraf.value = pcNameGraf
    Me.TextBox1.value = pcNamePage
    If Me.pcZnak = "+" Then
        Me.CmbZnak.ListIndex = 0
    Else
        Me.CmbZnak.ListIndex = 1
    End If
Else
    Me.CmbZnak.ListIndex = 0
End If
' Определим параметры формы от типа формулы
Select Case Me.pnTypeFormula
    Case 1 ' Вертикальный контроль
            Me.CmdGraf.Enabled = False
            Me.TxtGraf = "Все графы"
            Me.pnNumGraf = 0
    Case 4 ' Горизонтальный контроль
            Me.CmdBar.Enabled = False
            Me.TxtBar.value = "Все строки"
            Me.pnLinkStr = -1
End Select


End Sub

Private Sub CmbZNAK_Change()
    If Not Me.TxtBar = "" And Not Me.TxtGraf = "" Then
        Me.CmdOK.Enabled = True
    End If
End Sub

Private Sub CmdBar_Click()
Dim oldSheet As Worksheet

If Me.TextBox1.Text <> "" Then
    Set oldSheet = ActiveSheet
    Sheets(Me.TextBox1.Text).Activate
End If

If (TxtBar.Text <> "") And (VBA.Mid(TxtBar.Text, 1, 8) <> "Отобрано") Then
    Call SEEK_POP_GET_DATA(1, False)
Else
    Call SEEK_POP_GET_DATA(1, True)
End If
    If pbFormCancel Then
        pnCount = SEEK_POP.pcCount
        Me.TxtBar.value = SEEK_POP.pcRetValue
        If pnCount <= 1 Then
            'Me.TxtBar.value = SEEK_POP.pcRetValue
            Me.pcCodeStr = SEEK_POP.pcRetValue
            Me.pnLinkStr = VBA.Val(SEEK_POP.pcRetLink)
        Else
            pnRetArrayValue = SEEK_POP.pcRetArrayValue
            pnRetArrayText = SEEK_POP.pcRetArrayText
            pnRetArrayLink = SEEK_POP.pcRetArrayLink
        End If
        Unload SEEK_POP
        If Not Me.TxtBar = "" And Not Me.TxtGraf = "" Then
            Me.CmdOK.Enabled = True
        End If
    End If

If Me.TextBox1.Text <> "" Then
    oldSheet.Activate
End If

End Sub

Private Sub CmdExit_Click()
    Unload Me
End Sub

Private Sub CmdGraf_Click()
Dim oldSheet As Worksheet

If Me.TextBox1.Text <> "" Then
    Set oldSheet = ActiveSheet
    Sheets(Me.TextBox1.Text).Activate
End If
    
    Call SEEK_POP_GET_DATA(2, False)
    If pbFormCancel Then
        Me.TxtGraf.value = SEEK_POP.pcRetText
        Me.pcNameGraf = SEEK_POP.pcRetText
        Me.pnNumGraf = VBA.Val(SEEK_POP.pcRetLink)
        Unload SEEK_POP
        If Not Me.TxtBar = "" And Not Me.TxtGraf = "" Then
            Me.CmdOK.Enabled = True
        End If
    End If

If Me.TextBox1.Text <> "" Then
    oldSheet.Activate
End If
End Sub

Private Sub CmdOk_Click()
    pbFormCancel = True
    Me.pcZnak = Me.CmbZnak.value
    Me.Hide
End Sub

Private Sub CommandButton1_Click()
Call SEEK_POP_GET_DATA(0, False)
If pbFormCancel Then
    Me.TextBox1.Text = SEEK_POP.pcRetValue
    Me.pcNamePage = Me.TextBox1.Text
    Unload SEEK_POP
    Me.TxtBar.Text = ""
    Me.TxtGraf.Text = ""
    Me.CmdOK.Enabled = False
End If
End Sub

Private Sub Label2_Click()

End Sub

Private Sub Label6_Click()

End Sub

Private Sub UserForm_Initialize()
    If FORMULAEDIT.pnTypeFormula = 2 Then
        Me.CommandButton1.Enabled = True
    Else
        Me.CommandButton1.Enabled = False
    End If
    
    Me.CmbZnak.AddItem "+"
    Me.CmbZnak.AddItem "-"
    If FORMULAEDIT.pnTypeFormula = 1 Then
        Me.CmbZnak.AddItem "+ СУММ"
        Me.CmbZnak.AddItem "- СУММ"
    End If
Me.Caption = pcNameApp + Me.Caption
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 1 Or CloseMode = 0 Then
    pbFormCancel = False
End If

End Sub
