Print MSHFlexGrid
This function retrieves data from MSHFlex Grid and prints it directly to the printer. It determines whether the information should be printed landscape or portrait.
AI
KI-Zusammenfassung: 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.
Quellcode
Private Sub Command1_Click()
X = PrintMSHGrid(MSHFlexGrid1)
End Sub
Public Function PrintMSHGrid(ByVal GridToPrint As MSHFlexGrid) As Long
'This function retrieves data from MSHFlexGrid and prints it directly to the
'printer. It uses MyArray to store the distance between columns. The max number
'of columns is 50, but it can be increased if there is a need.
'Print information from mshflexgrid
Dim MyRows, MyCols As Integer 'for-loop counters
Dim MyText As String 'text to be printed
Dim Titles As String 'column titles
Dim Header As String 'page headers
Dim MyLines As Integer 'number of lines for portrait/landscape
Dim LLCount As Integer 'temporary line counter
Dim MyArray(50) As Integer
Screen.MousePointer = vbHourglass
Titles = ""
LLCount = 0
Header = " - Page: " 'setup page header
'get column headers
For MyCols = 0 To GridToPrint.Cols - 1
MyArray(MyCols) = Len(GridToPrint.ColHeaderCaption(0, MyCols)) + 15
Titles = Titles & Space(15) & GridToPrint.ColHeaderCaption(0, MyCols)
Next MyCols
'setup printer
Printer.Font.Size = 8 '8pts font size
Printer.Font.Bold = True 'titles to be bold
Printer.Font.Name = "Courier New" 'courier new font
'determine whether to print landscape or portrait
If (Len(MyText) > 120) Then 'landscape
Printer.Orientation = vbPRORLandscape
MyLines = 60
Else 'portrait
Printer.Orientation = vbPRORPortrait
MyLines = 85
End If
Printer.Print Header; Printer.Page
Printer.Print Titles
Printer.Font.Bold = False
'get column/row values
For MyRows = 1 To GridToPrint.Rows - 1
MyText = ""
GridToPrint.Row = MyRows
For MyCols = 0 To GridToPrint.Cols - 1
GridToPrint.Col = MyCols
MyText = MyText & GridToPrint.Text & Space(MyArray(MyCols) - Len(GridToPrint.Text))
Next MyCols
LLCount = LLCount + 1
If LLCount <= MyLines Then
Printer.Print MyText
Else
Printer.NewPage
Printer.Print Header; Printer.Page
Printer.Print Titles
Printer.Print MyText
LLCount = 0
End If
Next MyRows
Printer.EndDoc
Screen.MousePointer = vbNormal
End Function
<%
Set Cnn1 = Server.CreateObject("ADODB.Connection")
Set adoCmd = Server.CreateObject("ADODB.Command")
Dim sXML
' Set the dsn up to a database
Cnn1.Open "DSN=nwind;UID=sa;PWD="
Set adoCmd.ActiveConnection = Cnn1
' I'm sure there's a much more graceful way to do this....
adoCmd.CommandText = "select TableName=t1.[name], ColumnName=c1.[name], datatype=(select a1.[name] from dbo.systypes as a1 where a1.xusertype = c1.xusertype), c1.isnullable, c1.length, c1.colid from dbo.syscolumns as c1 inner join dbo.sysobjects as t1 on c1.id = t1.id where t1.xtype = 'U'"
Set tmpRST = adoCmd.Execute
sXML = "<?xml version=""1.0""?><tables>"
Dim sTable
Dim iColCount
Dim intIterator
iColCount = tmpRST.Fields.Count - 1
sTable = tmpRST.Fields("TableName")
sXML = sXML & "<table><name>" & tmpRST("TableName") & "</name>"
Do While Not tmpRST.EOF
If tmpRST.Fields("TableName") <> sTable Then
sXML = sXML & "</table><table><name>" & tmpRST.Fields("TableName") & "</name>"
End If
sXML = sXML & "<column>"
For intIterator = 1 To iColCount
sXML = sXML & "<" & tmpRST.Fields(intIterator).Name & ">" & tmpRST.Fields(intIterator) & "</" & tmpRST.Fields(intIterator).Name & ">"
Next
sXML = sXML & "</column>"
sTable = tmpRST.Fields("TableName")
tmpRST.MoveNext
Loop
sXML = sXML & "</table></tables>"
Response.Write sXML
%>
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine