我正在尝试在打印前获取记事本的页数,
我将记事本设置为wordwrap=true, FontSize=12, MarginRight=750, MarginLeft=750, MarginTop=1000, MarginBottom=1000,
大于70
页的列数等于1 and 51
页数等于1时的行数。
它正在工作但是我的公式有些错误,一些记事本页面可以,但有些不是。
我希望有人可以更正我所拥有的代码。
或者即使记事本设置被更改,是否有任何适当的代码可以完成这项工作,如果没有正确的方法来获取记事本页面,至少有人可以更正我拥有的代码。
谢谢。
Private Function GetNotepadNumPage(ByVal filename as string) as Integer
Dim sr As New StreamReader(filename)
Dim line As String = sr.ReadLine
Dim CharL(9999) As Integer
Dim pCount As Integer = 0
Dim pLine As Integer = 0
Do While Not sr.EndOfStream
line = sr.ReadLine()
CharL(pLine) = line.Length
pLine += 1
If pLine = 51 Then
pCount += 1
For i As Integer = 0 To pLine
If CharL(i) > 70 Then
pCount += 1
Exit For
End If
Next
pLine = 0
End If
Loop
sr.Close()
If (pLine <> 0) Then
pCount += 1
For i As Integer = 0 To pLine
If CharL(i) > 70 Then
pCount += 1
Exit For
End If
Next
End If
pagecount = pCount
Return pagecount
End Function