Need a little more infomation. Are you loading up and displaying this text in a textbox or richtextbox, or are you opening up the file and wanting to read it in either line by line or the whole thing and then wanting to print out only one page?
Hi! No , I do not displaying this text in a textbox or richtextbox and not going to read it !
The only thing I wish : to have ability to print ONLY selected page/s (in CommonDialog1.ShowPrinter ) .....
Well since you are wanting to print a text file and only wanting to print pages x, y, and z. You are going to need to read in the text file for the following reasons.
1. Does the text file have any kind of formatting? (Formatting meaning does it have linefeed/carrage returns contained or is it just one long string?)
2. If it is formatted somehow then will each line fit on a page printed at X font size.
3. You will need to know how many pages it is at X font size prior to to displaying the print dialog so you can pass it the max number of pages.
From VB's help file...
[tt]
Max, Min Properties (CommonDialog)
You can set the Max and Min properties for the following:
Font dialog box — return or set the smallest and largest font sizes displayed in the Sizelist box.
Print dialog box — return or set the minimum and maximum allowed values for the print range.
Syntax
object.Min [= points]
object.Max [= points]
object.Min [= number ]
object.Max [= number ]
The Max and Min property syntaxes have these parts:
Part Description
object Anobject expression that evaluates to an object in the Applies To list.
points Anumeric expression specifying the smallest and largest font sizes.
number A numeric expression specifying the minimum and maximum page numbers.
Remarks
With the Font dialog box, the cdlCFLimitSize flag must be set before using these properties.
With the Print dialog box, the Min property determines the smallest number the user can specify in the From text box. The Max property determines the largest number the user can specify in the To text box.
Data Type
Integer
[/tt]
So with that said you are going to need to become familiar with the "Open" statement, the "FreeFile" function, the "Line Input" function or the "Input" function, and the "Close" statement for reading in the text file.
For determining the size of the file you can use the "FileLen" function (but this can be misleading, see below) and for determining the length of a string you can use the "Len" function and while you are at it you will need to know the following string manuplation functions, InStr, InStrRev, Left, Right, Mid, and Trim.
Now for FileLen being misleading...
This String Is Two Bytes Less
Than These Two
Lines
The reason for this is because of the LineFeed/Carrage Return characters containd within the file. These characters would not be present in a string read in with the Line Input function, but they would be present or contained within the string if you used the Input function and specified enough bytes to read in the whole file (or just enough to read in the two lines).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.