Èíòåãðèðîâàííàÿ ñðåäà VB 6.0 îáðàáîòêè áàç äàííûõ

       

Ñïîñîá (íåïîñðåäñòâåííàÿ îáðàáîòêà òàáëèö)


          Ñïîñîáå 1 èíôîðìàöèîííàÿ ñâÿçü ìåæäó ôîðìàìè îñóùåñòâëÿåòñÿ ÷åðåç ãëîáàëüíûå ïåðåìåííûå, è â ïåðâóþ î÷åðåäü, ÷åðåç ìàññèâû è Iz, äîñòóïíûå âî âñ¸ì Ïðîåêòå.

        Ñèñòåìà Visual Basic 6.0  íå  ìîæåò  îñóùåñòâëÿòü äðóãîé  ñâÿçè ìåæäó ôîðìàìè. Ïîýòîìó â  Ñïîñîáå 2, íå èñïîëüçóþùåì  ãëîáàëüíûå ìàññèâû, ìû âûíóæäåíû îãðàíè÷èòüñÿ îäíîé îáúåäèí¸ííîé ôîðìîé (ðèñ. 6.5), ðàñïîëîæèâ íà íåé âñå ýëåìåíòû ôîðì  Form1 (ðèñ. 6.3)  è  Form2 (ðèñ. 6.4)  Ñïîñîáà 1 (çà èñêëþ÷åíèåì êíîïîê ïåðåõîäà Cmd3  è  Cmd6).

          Ñïîñîá 2 îñíîâûâàåòñÿ íà èñïîëüçîâàíèè Ìåòîäîâ ýëåìåíòîâ Data1 è  Data2

          Øàãè:

1.      Âûïîëíèòü ïóíêòû Ñïîñîáà 1:

         2 (íà ôîðìå Form1 êíîïêà Cmd1 äîëæíà èìåòü íàäïèñü “Postavka â ñåòêó Flp”), 3, 4, 5, 

         6 (êíîïêà Cmd5 äîëæíà èìåòü íàäïèñü “Izd â ñåòêó Fli”), 7, 8, 9.

 

   

  Ðèñ. 6.5.  Îáúåäèí¸ííàÿ ôîðìà äëÿ ðàáîòû ñ äâóìÿ òàáëèöàìè Postavka è Izd

     

 



2.      Ðàçðàáîòàòü ïðîöåäóðû Form1 (ðèñ. 6.5).  

         Ïðîöåäóðû (1) è (2)  ïåðåïèøóòñÿ â âèäå:

         Private Sub Cmd1_Click ( ) ïðîöåäóðà (1), ñ÷èòûâàíèå òàáëèöû Postavka  â ñåòêó Flp

             Dim I%, J%, K%

             Data1.RecordSet.MoveFirst                 ‘ïåðåõîä íà ïåðâóþ çàïèñü òàáëèöû Postavka

             K= Data1.RecordSet.RecordCount      ‘êîëè÷åñòâî çàïèñåé òàáëèöû Postavka

             L = Data1.RecordSet.Fields.Count       ‘êîëè÷åñòâî ïîëåé òàáëèöû Postavka

             Flp.Rows = K+1: Flp.Cols = L                ‘óñòàíîâëåíèå ðàçìåðîâ ñåòêè Flp

                                                                          For I = 1 To

K

                   For J = 1 To

L

   If  I=1 Then Flp. Flp.TextMatrix (I-1, J-1)=Data1.RecordSet.Fields(J-1). _

Name  

   Flp.TextMatrix

(I, J-1) = Text1(J-1) ‘èëè = Data1.RecordSet.Fields(J-1).Value

                       Next J

                       Data1.RecordSet.MoveNext            ‘ïåðåõîä ê ñëåäóþùåé çàïèñè


                 Next I

            End Sub

       

         Private Sub Cmd2_Click ( )  ïðîöåäóðà (2), ñîâìåñòíàÿ îáðàáîòêà òàáëèö ÁÄ

             Dim St(1 To 4) As Single ‘ ìàññèâ ñòîèìîñòè ïîñòàâëÿåìûõ èçäåëèé ïî êâàðòàëàì 

             Dim  V!                              ‘V – îáùèé âåñ èçäåëèé èñêîìîãî øèôðà

             Dim I%, J%, F%, L% 

             V = 0

             For L = 1 To 4         ‘îáíóëåíèå ìàññèâà St

                    St(L) = 0

            Next L

            Data1.RecordSet.MoveFirst           ‘óñòàíîâêà íà

1-þ çàïèñü òàáëèöû Postavka

                                                                                       For I = 1 To

Data1.RecordSet.RecordCount ‘ïî ñòðîêàì òàáëèöû Postavka

                                                                                              F=0         

                  Data2.RecordSet.MoveFirst     ‘óñòàíîâêà íà 1-þ çàïèñü òàáëèöû Izd

                  For J = 1 To Data2.RecordSet.RecordCount

‘ïî ñòðîêàì òàáëèöû Izd

                         If  Data2.RecordSet.Fields(1).Value=Data1.RecordSet.Fields(1).Value Then

                                                                                          For

L = 1 To 4

                                                St(L)=St(L)+Data1.RecordSet.Fields(L+1).Value*  _

                                                             Data2.RecordSet.Fields(2).Value

                                                V = V + Data1.RecordSet.Fields(L+1).Value_

                                                                  Data2.RecordSet.Fields(3).Value

                                        Next L

                                        F=1 : Exit For 

                         End If

                         Data2.RecordSet.MoveNext          ‘ê ñëåäóþùåé çàïèñè òàáëèöû Izd

                  Next J

                                                                                         If F = 0 Then Lbl2.Caption = “Òàáëèöû íå ñîãëàñîâàíû” : Exit Sub  



   àáëèöû íå ñîãëàñîâàí                                                                Data1.RecordSet.MoveNext ‘ê ñëåäóþùåé çàïèñè òàáëèöû Postavka

            Next I

            Lbl2.Caption = “Èñêîìûé âåñ=” & Str(V)

            For L=1 To 4

                   Lst1.List(L-1) = St(L)

            Next L

       End Sub

    

       Ïðîöåäóðà  (4)  ïåðåïèøåòñÿ áåç èçìåíåíèé èç ï. 10.

       Ïðîöåäóðà (5) áóäåò âûãëÿäåòü ñëåäóþùèì îáðàçîì:

       Private Sub Cmd1_Click ( )   ‘ïðîöåäóðà (5), ñ÷èòûâàíèå òàáëèöû Izd  â ñåòêó Fli

                Dim I%, J%, K%

                Data2.RecordSet.MoveFirst               ‘ïåðåõîä íà ïåðâóþ çàïèñü òàáëèöû Izd

                K= Data2.RecordSet.RecordCount    ‘êîëè÷åñòâî çàïèñåé òàáëèöû Izd

                L = Data2.RecordSet.Fields.Count     ‘êîëè÷åñòâî ïîëåé  òàáëèöû Izd  

Fli.Rows = K+1: Fli.Cols = L               ‘óñòàíîâëåíèå ðàçìåðîâ ñåòêè Flp

                For I = 1 To K     

                       For J = 1 To L

       If  I=1 Then Fli.TextMatrix

(I-1, J-1)=Data2.RecordSet.Fields(J-1). _

Name  

Fli.TextMatrix

(I, J-1) = Text2(J-1) ‘èëè = Data2.RecordSet.Fields(J-1).Value

                       Next J

                       Data2.RecordSet.MoveNext            ‘ïåðåõîä ê ñëåäóþùåé çàïèñè

                Next I

          End Sub

       Äåéñòâèÿ:  

                         - çàïóñòèòü Ïðîåêò;

                   - íàæàòü Cmd1  (ñ÷èòûâàíèå

òàáëèöû Postavka  â ñåòêó Flp);

                   -  íàæàòü Cmd5 (ñ÷èòûâàíèå

òàáëèöû  Izd  â ñåòêó Fli);

                   - íàæàòü Cmd2  (îñóùåñòâëÿåòñÿ ñîâìåñòíàÿ îáðàáîòêà òàáëèö Postavka è Izd);

                   - íàæàòü Cmd4 (âûõîä èç Ïðîåêòà).

  

 


Ñîäåðæàíèå ðàçäåëà