Advertisement
2_2002-2004 DDE #117635

PrintGrid

To Print DataBase Grid Control as a quick report without buying an expensive tools.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
Please,If you do any changes let me know as a feed back.
If you like to have a .OCX as an Activex Email me, free no charge
but no source code. 
Private Function PrintGd(ByVal GridToPrint As DBGrid, ByVal MyRecordset As Recordset) As Long
Dim x, v, b
Dim Putit As String
Dim Myrec
Dim MyField
Dim TCapion
Dim Mydash
 Screen.MousePointer = 11
 
 Open "C:\Printed.txt" For Output As #2
 Putit = ""
 Mydash = "-"
 
 For b = 0 To GridToPrint.Columns.Count - 1
  Myrec = ""
  MyField = ""
  x = GridToPrint.Columns(b).Width
  x = x / 100
  For v = 1 To x
  Mydash = Mydash + "-"
   If Mid(GridToPrint.Columns(b).Caption, v, 1) = "" Then
    Myrec = Chr(32)
   Else
    Myrec = Mid(GridToPrint.Columns(b).Caption, v, 1)
   End If
    MyField = MyField & Myrec
  Next v
   Putit = Putit & Chr(9) & MyField
   DoEvents
 '
 Next b
 Print #2, " No" & Putit
 Print #2, Mydash
Close #2
   
Dim Colcap
Dim Toprint

Open "C:\Printed.txt" For Append As #1
MyRecordset.MoveFirst
Dim Nox
Do While Not MyRecordset.EOF
Putit = ""
Nox = Nox + 1
For b = 0 To GridToPrint.Columns.Count - 1
If GridToPrint.Columns(b).Visible = True Then
  Myrec = ""
  MyField = ""
  x = GridToPrint.Columns(b).Width
  x = x / 100
  For v = 1 To x
  DoEvents
   If Mid(GridToPrint.Columns(b).Text, v, 1) = "" Then
    Myrec = Chr(32) 'x
   Else
    Myrec = Mid(GridToPrint.Columns(b).Text, v, 1)
   End If
   MyField = MyField & Myrec
  Next v
  DoEvents
  Putit = Putit & Chr(9) & MyField
 Else
 End If
 
 Next b
 Print #1, Format(Nox, "@@@") & Putit

MyRecordset.MoveNext
Loop
 
Close #1
Me.Refresh
Dim RetVal As Long
  RetVal = ShellExecute(Me.hwnd, _
   vbNullString, "C:\Printed.Txt", vbNullString, "c:\", SW_SHOWNORMAL)
Screen.MousePointer = 0
End Function
Private Sub Command1_Click()
Dim x
x = PrintGd(DBGrid1, Data1.Recordset)
End Sub

<br /><h3>Simple PHP Template Class</h3>
<p><font size="2">The purpose of this tutorial is to show you how to implement a
simple class to handle page templates.&nbsp; It can be extended in any way you
wish.</font></p>
<p><b><font size="2">The Class (template.class.php)</font></b></p>
<p><code>&lt;?<br>
class Template {<br>
&nbsp;&nbsp; public $template;<br>
&nbsp;&nbsp; function load($filepath) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this-&gt;template = file_get_contents($filepath);<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; function replace($var, $content) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $this->template = str_replace("#$var#", $content, $this->template);<br>
&nbsp;&nbsp; }<br>
&nbsp;&nbsp; function publish() {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;		eval(&quot;?&gt;&quot;.$this-&gt;template.&quot;&lt;?&quot;);<br>
&nbsp;&nbsp; }<br>
}<br>
?&gt;</code></p>
<p><b><font size="2">The Template File (design.html)</font></b></p>
<p><font size="2">This file will contain the design of your web site and the
blank fields that will be merged with content data.</font></p>
<p><font size="2">&lt;html&gt;<br>
&lt;head&gt;<br>
&lt;title&gt;#title#&lt;/title&gt;<br>
&lt;/head&gt;<br>
&lt;body&gt;<br>
&lt;h3&gt;Hello #name#!&lt;/h3&gt;<br>
&lt;p&gt;The time is: #datetime#&lt;/p&gt;<br>
&lt;? echo &quot;&lt;p&gt;Embedded PHP works too!&lt;/p&gt;&quot;; ?&gt;<br>
&lt;/body&gt;<br>
&lt;/html&gt;</font></p>
<p><b><font size="2">Usage (index.php)</font></b></p>
<p><font size="2">Now we will create a script that load the template and use the
class to merge the data.</font></p>
<p><code>&lt;?<br>
include &quot;template.class.php&quot;;</code></p>
<p><code>$template = new Template;<br>
$template-&gt;load(&quot;design.html&quot;);<br>
$template-&gt;replace(&quot;title&quot;, &quot;My Template Class&quot;);<br>
$template-&gt;replace(&quot;name&quot;, &quot;William&quot;);<br>
$template-&gt;replace(&quot;datetime&quot;, <span class="default">date</span><span class="keyword">(</span><span class="string">&quot;m/d/y&quot;</span><span class="keyword">)</span>);<br>
$template->publish();<br>
?></code></p>
<p><font size="2">When you run the above script, index.php, it will output the
following:</font></p>
<p><font size="2">&nbsp;&lt;html&gt;<br>
&lt;head&gt;<br>
&lt;title&gt;My Template Class&lt;/title&gt;<br>
&lt;/head&gt;<br>
&lt;body&gt;<br>
&lt;h3&gt;Hello William!&lt;/h3&gt;<br>
&lt;p&gt;The time is: 03/10/04&lt;/p&gt;<br>
&lt;p&gt;Embedded PHP works too!&lt;/p&gt;<br>
&lt;/body&gt;<br>
&lt;/html&gt;</font></p>
<p><font size="2">This code, as you can see, is very simple.&nbsp; It supports
embedding PHP into the original template file (design.html).&nbsp; You could
easily extend it to pull data from a database such as MySQL.</font></p>

Upload
Commenti originali (3)
Recuperato da Wayback Machine