我?guī)湍惆炎詈笠徊糠值恼Z句順序調(diào)換一下。你試一試
網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、成都微信小程序、集團企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了平?jīng)雒赓M建站歡迎大家使用!
sub button1_click() '---執(zhí)行打印
Dim pd As PrintDocument = New PrintDocument
pd.PrinterSettings = PrintDialog1.PrinterSettings
If _PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
for i=0 to 1 '這樣可以兩次截圖
CaptureScreen() '--執(zhí)行前面自定義函數(shù)截圖
AddHandler pd.PrintPage, AddressOf Document_PrintPage
pd.Print()
Threading.Thread.sleep(100) ‘ 再加上一個間隔
next
end sub
參考:
把執(zhí)行SQL語句后得到的記錄集逐條(含字段名)顯示在LISTVIEW控件中
'----------------------------------------------------------------
Public Sub ListUpdate(ByRef rs As Recordset, ByRef lv As ListView)
Dim head As ColumnHeader, Item As ListItem
Dim i As Integer, j As Integer
Dim lvWidth As Integer
lvWidth = lv.Width
'初始化LISTVIEW的某些屬性
lv.View = lvwReport
lv.GridLines = True
lv.FullRowSelect = True
lv.ListItems.Clear
lv.ColumnHeaders.Clear
For i = 0 To rs.Fields.Count - 1
Set head = lv.ColumnHeaders.Add
head.Text = rs.Fields(i).Name
head.Width = lvWidth / rs.Fields.Count
Next
For j = 1 To PERPAGE
If rs.EOF Then Exit For
Set Item = lv.ListItems.Add
Item.Text = "" rs.Fields(0).Value
For i = 1 To rs.Fields.Count - 1
Item.SubItems(i) = "" rs.Fields(i).Value
Next
rs.MoveNext
Next
End Sub
' 打印
Public Sub PrintRecordset(ByRef recRecordset As Recordset, ByVal strType As String)
Dim LeftMargin As Integer
Dim HeadTopPosition As Integer
Dim FieldNum As Integer
Dim PageCounter As Integer
Dim MyRecordset As ADODB.Recordset
Const FooterTopPosition = 24
Set MyRecordset = recRecordset
PageCounter = 1
' 設(shè) 置Printer 對 象 坐 標 的 度 量 單 位 為 厘 米
Printer.ScaleMode = vbCentimeters
LeftMargin = 1.5
HeadTopPosition = 2
' 定 義 打 印 頁 左 上 角 的X 坐 標 和Y 坐 標, 通 過 改 變ScaleLeft 和ScaleTop 的 值, 可 改 變 打 印 頁 的 左 邊 距 和 上 邊 距
Printer.ScaleLeft = -LeftMargin
Printer.ScaleTop = -HeadTopPosition
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 12
Printer.Print "音像店顧客管理系統(tǒng)"
Printer.Print strType
Printer.Print ""
If MyRecordset.EOF And MyRecordset.BOF Then
MsgBox "No Record At Presend!", vbCritical And vbOKOnly, "Print Error"
Exit Sub
End If
MyRecordset.MoveFirst
Do Until Printer.CurrentY FooterTopPosition
'Print the fields of the recordset in sequence
For FieldNum = 0 To MyRecordset.Fields.Count - 1
Printer.Print MyRecordset.Fields(FieldNum).Name _
": " _
MyRecordset.Fields(FieldNum).Value
If Printer.CurrentY FooterTopPosition Then
Printer.CurrentX = 8
Printer.Print "Page: " PageCounter
' 創(chuàng) 建 多 頁 文 檔
Printer.NewPage
PageCounter = PageCounter + 1
End If
Next FieldNum
MyRecordset.MoveNext
If MyRecordset.EOF Then Exit Do
' 在 記 錄 之 間 空 一 行
Printer.Print ""
Loop
'Print the Page number as a footer
Printer.CurrentX = 8
Printer.CurrentY = FooterTopPosition
Printer.Print "Page: " PageCounter
' 將 輸 出 送 到 打 印 機
Printer.EndDoc
End Sub
Dim A(50) As Integer
Private Sub Command1_Click()
Randomize
For i = 1 To 50
A(i) = Int(Rnd * 90 + 10)
Next i
Picture1.Cls
Picture1.Print "排序前數(shù)據(jù):"
For i = 1 To 50
Picture1.Print A(i);
If i Mod 10 = 0 Then Picture1.Print
Next
End Sub
Private Sub Command2_Click()
For i = 1 To 49
Max = A(i)
For j = i + 1 To 50
If A(j) Max Then
Max = A(j)
temp = A(i): A(i) = A(j): A(j) = temp
End If
Next
Next
Picture1.Print "排序后數(shù)據(jù):"
For i = 1 To 50
Picture1.Print A(i);
If i Mod 10 = 0 Then Picture1.Print
Next
End Sub
你直接傳一個數(shù)組進去,而且是一個結(jié)構(gòu)體數(shù)組,array.sort怎么知道根據(jù)結(jié)構(gòu)中的哪一個屬性進行排序?放一個c#的代碼你看看,VB和C#很相似的
class Program
{
static void Main(string[] args)
{
People[] p = new People[3]
{
new People{name="張三"},
new People{name="李四"},
new People{name="張二名"}
};
//重點傳一個實現(xiàn)了IComparer接口的類進去,告訴Array.Sort怎么排序
Array.Sort(p, new PeopleCompare());
foreach (var item in p)
{
Console.WriteLine(item.name);
}
Console.ReadKey();
}
}
//People結(jié)構(gòu)體,換成類一樣的
public struct People
{
public string name { get; set; }
}
//實現(xiàn)了IComparer接口的類
public class PeopleCompare : IComparer
{
public int Compare(object x, object y)
{
People p1 = (People)x ;
People p2 = (People)y;
return p1.name.CompareTo(p2.name);
}
}