PrintGrid
To Print DataBase Grid Control as a quick report without buying an expensive tools.
AI
Resumo por IA: 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.
Código fonte
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. 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><?<br>
class Template {<br>
public $template;<br>
function load($filepath) {<br>
$this->template = file_get_contents($filepath);<br>
}<br>
function replace($var, $content) {<br>
$this->template = str_replace("#$var#", $content, $this->template);<br>
}<br>
function publish() {<br>
eval("?>".$this->template."<?");<br>
}<br>
}<br>
?></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"><html><br>
<head><br>
<title>#title#</title><br>
</head><br>
<body><br>
<h3>Hello #name#!</h3><br>
<p>The time is: #datetime#</p><br>
<? echo "<p>Embedded PHP works too!</p>"; ?><br>
</body><br>
</html></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><?<br>
include "template.class.php";</code></p>
<p><code>$template = new Template;<br>
$template->load("design.html");<br>
$template->replace("title", "My Template Class");<br>
$template->replace("name", "William");<br>
$template->replace("datetime", <span class="default">date</span><span class="keyword">(</span><span class="string">"m/d/y"</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"> <html><br>
<head><br>
<title>My Template Class</title><br>
</head><br>
<body><br>
<h3>Hello William!</h3><br>
<p>The time is: 03/10/04</p><br>
<p>Embedded PHP works too!</p><br>
</body><br>
</html></font></p>
<p><font size="2">This code, as you can see, is very simple. It supports
embedding PHP into the original template file (design.html). You could
easily extend it to pull data from a database such as MySQL.</font></p>
Upload
Comentários originais (3)
Recuperado do Wayback Machine