views:

174

answers:

4

in vb.net i have some code that looks like this:

Imports System
Imports System.IO
Imports iTextSharp.text
Imports iTextSharp.text.pdf

Public Class Form1

    Public Sub New1()
        Directory.SetCurrentDirectory("C:\Users\alexluvsdanielle\Desktop\") '"
        Console.WriteLine("Chapter 10 example 10: nested PdfPTables") 
        Dim doc As Document = New Document(PageSize.A4, 50, 50, 50, 50)

        Try
            Dim writer As PdfWriter = PdfWriter.GetInstance(doc, New FileStream("Chap1010.pdf", FileMode.Create))
            doc.Open()
            Dim table As PdfPTable = New PdfPTable(4)
            Dim nested1 As PdfPTable = New PdfPTable(2)
            nested1.AddCell("1.1")
            nested1.AddCell("1.2")
            Dim nested2 As PdfPTable = New PdfPTable(1)
            nested2.AddCell("2.1")
            nested2.AddCell("2.2")
            Dim k As Integer = 0
            While k < 24
                If k = 1 Then
                    table.AddCell(nested1)
                Else
                    If k = 20 Then
                        table.AddCell(nested2)
                    Else
                        table.AddCell("cell " + k)
                    End If
                End If
                System.Threading.Interlocked.Increment(k)
            End While
            table.TotalWidth = 300
            table.WriteSelectedRows(0, -1, 100, 600, writer.DirectContent)
            doc.Close()

        Catch de As Exception
            Console.Error.WriteLine(de.Message)
            Console.Error.WriteLine(de.StackTrace)
        End Try
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        New1()
        End  
    End Sub

End Class

i would like to see what the console is writing. how do i do this?

A: 

There is no Console in a Winforms application.

You will need to use a MessageBox to display your message.

MessageBox.Show(de.Message)

Alan
+2  A: 
Joel Coehoorn
+1  A: 

I have piped the output of a WinForms application by starting it from the command line:

myapp.exe > debugfile.txt

I've done that before to redirect the output to a file that I can then read.

Erich Mirabal
+1  A: 

Why not use Debug.Print ? it will show up in the output window while developing and is much cleaner then a bunch of Message boxes everywhere...

Robert French