189 8069 5689

vb.net按顺序打印 vb 打印指定文件

vb.net Document_PrintPag 打印

我帮你把最后一部分的语句顺序调换一下。你试一试

网站建设哪家好,找成都创新互联!专注于网页设计、网站建设、微信开发、成都微信小程序、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了平凉免费建站欢迎大家使用!

sub button1_click() '---执行打印

Dim pd As PrintDocument = New PrintDocument

pd.PrinterSettings = PrintDialog1.PrinterSettings

If _PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

for i=0 to 1 '这样可以两次截图

CaptureScreen() '--执行前面自定义函数截图

AddHandler pd.PrintPage, AddressOf Document_PrintPage

pd.Print()

Threading.Thread.sleep(100) ‘ 再加上一个间隔

next

end sub

VB.NET打印问题(有滚动条控件的内容怎么全部打印)

参考:

把执行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

' 设 置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 "音像店顾客管理系统"

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

' 创 建 多 页 文 档

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

VB用随机函数产生50个【10-100】的随机整数,并按照从小到大的顺序打印出来

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 "排序前数据:"

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 "排序后数据:"

For i = 1 To 50

Picture1.Print A(i);

If i Mod 10 = 0 Then Picture1.Print

Next

End Sub

VB.net 数组怎么按任意元素的顺序排序输出

你直接传一个数组进去,而且是一个结构体数组,array.sort怎么知道根据结构中的哪一个属性进行排序?放一个c#的代码你看看,VB和C#很相似的

class Program

{

static void Main(string[] args)

{

People[] p = new People[3]

{

new People{name="张三"},

new People{name="李四"},

new People{name="张二名"}

};

//重点传一个实现了IComparer接口的类进去,告诉Array.Sort怎么排序

Array.Sort(p, new PeopleCompare());

foreach (var item in p)

{

Console.WriteLine(item.name);

}

Console.ReadKey();

}

}

//People结构体,换成类一样的

public struct People

{

public string name { get; set; }

}

//实现了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);

}

}


新闻标题:vb.net按顺序打印 vb 打印指定文件
网站网址:http://jkwzsj.com/article/dojsiii.html

其他资讯