Option expedition
PUBLIC FUNCTION FORMATDATA2 (Byval Data1 As Double, Byval Data2 As Double) AS String Dim DT1, DT2 AS Double DT1 = DATA1 DT2 = DATA2 IF DT1 = 0 OR DT1 = 0 # or DT2 = 0 OR DT2 = 0 # THEN FORMATDATA2 = " 0.00 "Else formatdata2 = format (Round (DT1 / DT2, 2)," 0.00 ") end fnd function
Public Sub print_jian_anhuizong (ByRef printCtl As VSPrinter, ByVal strTable As String, ByVal strTitle) Dim con As New ADODB.Connection Dim rst As New ADODB.Recordset Dim str_table As String Dim str_title As String Dim strSql As String Dim iCurrent As Integer Dim cols As Integer 'page table Columns DIM ICURENROWS AS INTEGER' page Top Total number DIM ROWS AS Long 'Total number DIM TROWS AS Long' Page Table Total number DIM Pages AS INTEGER 'Total number DIM iPage AS Integer' Current page Dim iLastrows As integer 'remaining after full page display the number of rows Dim iRow As Long' position of the current row On Error GoTo err1 str_table = strTable str_title = strTitle con.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = "& strConnection &"; Persist Security Info = False "con.Open strSql =" select nn, name, unit, pricezhijiegongcheng, pricezhijie, pricerengong, pricecailiao, pricejixie, "& _" priceqitazhijie, pricexianchang, pricejianjie, pricejihualirun, priceshuijin, priceshashijiacha , Price1 from "& str_table &" order by nn "Rst.c ursorType = adOpenKeyset rst.LockType = adLockOptimistic rst.Open strSql, con,,, adCmdText cols = 13 If Not rst.BOF And Not rst.EOF Then 'obtain the total number of records rows rst.MoveFirst Do While Not rst.EOF Rows = ROWS 1 RST.MOVENEXT LOOP 'Reset Row The location of the row is the first record RST.MoveFirst' Set the total page number if rows <= 18 THEN 'total number of large lines is equal to the total number of large lines displayed Pages = 1 icrrenrows = rows ilhastrows = 0 Else 'The total number of total lines is larger than the page displayed on the page IF ROWS MOD 18 = 0 THEN'
Total number equal to the total bank displayed by the page Pages = int (rows / 18) ilhastrows = 0 else 'The total number of banks is not equal to the total number of multiples displayed by the page Pages = int (ROWS / 18) 1 Ilastrows = Rows MOD 18 End if icrrenrows = 18 end if ipage = 1 'Set the current page IROW = 0' Set the current line location is empty 'with printctl .orientation = orlandscape' Sets the horizontal print .tableborder = tball 'Set the margin of the four sides. Margintop = 1400.Marginbottom = 1400 .Marginleft = 1400 .Marginright = 1400 'Set font name' ***************************************************** ***** Start printing documentation ******************************************** .startDoc. Startdoc .Tablepen = 20 for ipage = 1 to pies' Settings Title .FontSize = 14 .fontbold = true .textalign = Tacentermiddle .paragraph = str_title .paragraph = "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" .FontSize = 10 'disposed page table .FontSize = 9 .StartTable .TextAlign = taRightMiddle .Paragraph = "unit:" .StartTable .TableCell (tcCols) = cols If iPage = pages And iLastrows <> 0 Then Trows = iLastrows 2 Else TROWS = ICURRENROWS 2 end if .tablecell (tcrows) = trows' /// .tablecell (tcrowheight) =
400 .Tablecell (TcColwidth,, 1) = 600 .tablecell (TcColwidth,, 2) = 2600 .tablecell (TcColwidth,, 3) = 1000 .tablecell (TcColwidth,, 4) = 1000 .Tablecell (TcColwidth,,,, 5) = 1000 .Tablecell (TcColwidth,, 6) = 1000 .Tablecell (TcColwidth,, 7) = 1000 .Tablecell (TcColwidth,, 8) = 1000 .tablecell (TcColwidth,, 9) = 1000 .tablecell (TcColwidth,,,, 10) = 1000 .Tablecell (TcColwidth,, 11) = 1000 .tablecell (TcColwidth,, 12) = 1000 .tablecell (TcColwidth,, 13) = 1000 .tablecell (Tccolspan, 1, 4) = 10 .tablecell (TCROWSPAN, 1, 1 ) = 2 .Tablecell (TCROWSPAN, 1, 2) = 2 .Tablecell (TCROWSPAN, 1, 3) = 2 '/// .tablecell (tcText, 1, 1) = "Sequence" .Tablecell (TCText, 1, 2 ) = "Engineering unit price name" .Tablecell (tcText, 1, 3) = "unit price" .Tablecell (TCText, 1, 4) = "" "" .Tablecell (TCText, 2, 4) = "Total fee" .tablecell (TCText, 2, 5) = "Material fee" .Tablecell TcText, 2, 6) = "Machine fee" .Tablecell (TCText, 2, 7) = "Other direct fees" .Tablecell (TCText, 2, 8) = "Field funds" .Tablecell (TCText, 2, 9) = "Direct engineering fee" .Tablecell (TCText, 2, 10) = "indirect fee" .tablecell (tcText, 2, 11) = "Plan Profit" .Tablecell (TCText, 2, 12) = "Tax"
.Tablecell (TCText, 2, 13) = "Materials" '/// .Tablecell (Tcalign, 1, 1, 1, 13) = Tacentermiddle' Title Title Title Targes. Tablecell (Tcalign, 2, 4, 2, 13 = Tacentermiddle 'Title line is aligned. Tablecell (Tcalign, 3, 1, trows, 1) = Tacentermiddle' first column is aligned .Tablecell (Tcalign, 3, 2, trows, 2) = taleftmiddle 'second column of the second column Align .Tablecell (Tcalign, 3, 3, TROWS, 13) = TARIGHTMIDDLE 'Other columns in the right alignment' ************************************ ********** Add data to each page ******************************************** *** icrrent = 0 do while not rst.eof irow = irow 1 'When the current page data is added, the loop is exited, starting the next page if Icurrent <> 0 and icrrent mod 18 = 0 Then EXIT DO End if .tablecell (TCText, 3 icrrent, 1) = Rst.fields ("NN") & "" .Tablecell (TCText, 3 icRrent, 2) = Rst.fields ("Name") & "" .Tablecell (tcText, 3 IC URRRENT, 3) = formatdata2 (Val (Rst.fields ("Price1") & ""), Val (Rst.Fields ("Unit") & "")) .Tablecell (TCText, 3 icrrent, 4) = formatdata2 (Val (Rst.Fields ("Pricrengong") & ""), Val ("Unit") & "")) .TableCell (TCText, 3 icrrent, 5) = formatdata2 (Val (Rst.fields ("Pricecailiao") & ""), Val (Rst.fields ("Unit") & "")) .tablecell (TCText, 3 icrrent, 6) =
Formatdata2 (Val ("PriceJixie" & "), Val (Rst.Fields (" Unit ") &")) .tablecell (TCTEXT, 3 ICURRENT, 7) = FormatData2 (Val (RST. Fields ("PriceQitazhijie") & ""), Val ("Unit") & "")) .tablecell (TCText, 3 icrrent, 8) = formatdata2 (Val (Rst.Fields ("PricexianChang") & ""), Val ("Unit") & "")) .Tablecell (TCText, 3 icrrent, 9) = formatdata2 (Val (Rst.Fields ("Pricezhijiegongcheng" & "), VAL (Rst.fields ("Unit") & "")) .Tablecell (TCText, 3 icrrent, 10) = formatdata2 (Val (Rst.Fields ("Pricejianjie") & "), Val (Rst.fields (" Unit ") &" ")) .Tablecell (TCText, 3 icrrent, 11) = formatdata2 (Val (Rst.Fields (" PricejihuAlun ") &"), Val (Rst.Fields ("Unit") & "" ))) .Tablecell (TCText, 3 icrrent, 12) = formatdata2 (Val (Rst.fields ("PriceShuijin" & "), Val (Rst.Fields (" Unit ") &")) .tablecell (TCText , 3 icrrent, 13) = formatdata2 (Val (Rst.fie LDS ("PriceShashijiaCha") & ""), Val ("Unit") & ")) Rst.MOVENEXT ICURRENT = ICURRENT 1 loop .endtable 'Judging whether the current record is the last one, if not The last one, starting a new page if irow