Click here to Skip to main content
15,910,981 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Secure Code to Reflector Pin
Anubhava Dimri19-Nov-09 17:39
Anubhava Dimri19-Nov-09 17:39 
GeneralRe: Secure Code to Reflector Pin
Anubhava Dimri19-Nov-09 17:09
Anubhava Dimri19-Nov-09 17:09 
Questionlower case to upper case but looks like something else is going on Pin
VB 12318-Nov-09 16:49
VB 12318-Nov-09 16:49 
AnswerRe: lower case to upper case but looks like something else is going on Pin
Dave Kreskowiak18-Nov-09 17:26
mveDave Kreskowiak18-Nov-09 17:26 
GeneralRe: lower case to upper case but looks like.... SOLVED Pin
VB 12319-Nov-09 3:33
VB 12319-Nov-09 3:33 
GeneralRe: lower case to upper case but looks like.... SOLVED Pin
Dave Kreskowiak19-Nov-09 3:38
mveDave Kreskowiak19-Nov-09 3:38 
GeneralRe: lower case to upper case but looks like.... SOLVED Pin
VB 12320-Nov-09 12:37
VB 12320-Nov-09 12:37 
GeneralUnexpected characters in print ouptut - VB2008 Pin
rbc102518-Nov-09 10:48
rbc102518-Nov-09 10:48 
Hi.
I have a rather perplexing problem when printing a file.
My application reads a file in from a folder, lists it in a ListView control and then sends it to the printer.The problem I'm having is that when I send it to a printer the text is preceded by half a page of block characters before the actual text starts. As a sanity check, I went back and tried printing from a textbox on my form and it worked perfectly.
Does anyone have any ideas on how I can look at the bytes coming in from the file and going out to the printer or what may be wrong?
Here is my print code:

Private Sub PrtTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrtTest.Click
        Try
            Dim _fs As FileStream
            _fs = New FileStream("C:\Components\Test-Page1.txt",     FileMode.Open, FileAccess.Read)

            _Printstream = New StreamReader(_fs)

            Dim pd As New PrintDocument()

            AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
            pd.PrinterSettings.PrinterName = _printername
            PrintPreviewDialog2.Document = pd
            PrintPreviewDialog2.ShowDialog()
            If pd.PrinterSettings.IsValid Then
                pd.Print()
            Else
                MessageBox.Show("Printer is invalid.")
            End If

        Catch ex As Exception
            MessageBox.Show("An error occurred while printing", _
                 ex.ToString())
        End Try
    End Sub

Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)

        Dim numChars As Integer
        Dim numLines As Integer
        Dim stringForPage As String
        Dim strFormat As New StringFormat
        Dim PrintFont As New Font("Arial", 10, FontStyle.Regular)
        Dim PrintString As String = _Printstream.ReadToEnd
        Dim rectDraw As New RectangleF( _
          ev.MarginBounds.Left, ev.MarginBounds.Top, _
          ev.MarginBounds.Width, ev.MarginBounds.Height)

        Dim sizeMeasure As New SizeF(ev.MarginBounds.Width, _
          ev.MarginBounds.Height - PrintFont.GetHeight(ev.Graphics)) 
        'PrintString = _Printstream.ReadToEnd()
        strFormat.Trimming = StringTrimming.Word 

        ev.Graphics.MeasureString(PrintString, PrintFont, _
          sizeMeasure, strFormat, numChars, numLines)

        stringForPage = PrintString.Substring(0, numChars) 
        ev.Graphics.DrawString(stringForPage, PrintFont, _
          Brushes.Black, rectDraw, strFormat)

        If numChars < PrintString.Length Then           
            PrintString = PrintString.Substring(numChars) 
            ev.HasMorePages = True
        Else
            ev.HasMorePages = False         

        End If

    End Sub 

GeneralRe: Unexpected characters in print ouptut - VB2008 Pin
DaveAuld18-Nov-09 11:06
professionalDaveAuld18-Nov-09 11:06 
GeneralRe: Unexpected characters in print ouptut - VB2008 Pin
rbc102518-Nov-09 17:06
rbc102518-Nov-09 17:06 
QuestionProblem in VB while trying to execute SQL Code Pin
nhsal6918-Nov-09 3:37
nhsal6918-Nov-09 3:37 
AnswerRe: Problem in VB while trying to execute SQL Code Pin
Eduard Keilholz18-Nov-09 4:08
Eduard Keilholz18-Nov-09 4:08 
GeneralRe: Problem in VB while trying to execute SQL Code Pin
nhsal6918-Nov-09 4:17
nhsal6918-Nov-09 4:17 
GeneralRe: Problem in VB while trying to execute SQL Code Pin
Luc Pattyn18-Nov-09 5:02
sitebuilderLuc Pattyn18-Nov-09 5:02 
AnswerRe: Problem in VB while trying to execute SQL Code Pin
The Man from U.N.C.L.E.18-Nov-09 8:01
The Man from U.N.C.L.E.18-Nov-09 8:01 
GeneralRe: Problem in VB while trying to execute SQL Code Pin
nhsal6918-Nov-09 21:13
nhsal6918-Nov-09 21:13 
GeneralRe: Problem in VB while trying to execute SQL Code Pin
Ashfield18-Nov-09 21:30
Ashfield18-Nov-09 21:30 
GeneralRe: Problem in VB while trying to execute SQL Code Pin
nhsal6918-Nov-09 23:08
nhsal6918-Nov-09 23:08 
GeneralRe: Problem in VB while trying to execute SQL Code Pin
Ashfield19-Nov-09 1:25
Ashfield19-Nov-09 1:25 
GeneralRe: Problem in VB while trying to execute SQL Code Pin
The Man from U.N.C.L.E.18-Nov-09 22:44
The Man from U.N.C.L.E.18-Nov-09 22:44 
QuestionConsole application Pin
offroaderdan17-Nov-09 23:35
offroaderdan17-Nov-09 23:35 
AnswerRe: Console application Pin
Richard MacCutchan18-Nov-09 0:05
mveRichard MacCutchan18-Nov-09 0:05 
AnswerRe: Console application Pin
Dave Kreskowiak18-Nov-09 8:35
mveDave Kreskowiak18-Nov-09 8:35 
AnswerRe: Console application Pin
Ian Shlasko18-Nov-09 10:27
Ian Shlasko18-Nov-09 10:27 
AnswerRe: Console application [modified] Pin
DaveAuld18-Nov-09 11:02
professionalDaveAuld18-Nov-09 11:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.