Click here to Skip to main content
15,909,030 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How do i get an image to appear in a picture box using the open file dialog?? Pin
Christian Graus29-Jan-07 23:41
protectorChristian Graus29-Jan-07 23:41 
GeneralRe: How do i get an image to appear in a picture box using the open file dialog?? Pin
China-Gary29-Jan-07 23:59
China-Gary29-Jan-07 23:59 
AnswerRe: How do i get an image to appear in a picture box using the open file dialog?? Pin
IqbalVB30-Jan-07 9:21
IqbalVB30-Jan-07 9:21 
QuestionHow to schedule a DB Job from Code Pin
suyh8229-Jan-07 23:03
suyh8229-Jan-07 23:03 
Questionchange date back color in monthcalander Pin
Neeraj Arora29-Jan-07 23:00
Neeraj Arora29-Jan-07 23:00 
QuestionHow I Can Print a File ? Pin
Yadav A Kumar29-Jan-07 22:13
Yadav A Kumar29-Jan-07 22:13 
AnswerRe: How I Can Print a File ? Pin
Vasudevan Deepak Kumar29-Jan-07 22:27
Vasudevan Deepak Kumar29-Jan-07 22:27 
AnswerRe: How I Can Print a File ? Pin
IqbalVB30-Jan-07 9:30
IqbalVB30-Jan-07 9:30 
You can use this, and change the filepath as you need:
<br />
    Private printFont As Font<br />
    Private streamToPrint As StreamReader<br />
    Private Shared filePath As String<br />
--------------------------------------------------<br />
    ' The PrintPage event is raised for each page to be printed.<br />
    Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)<br />
        Dim linesPerPage As Single = 0<br />
        Dim yPos As Single = 0<br />
        Dim count As Integer = 0<br />
        Dim leftMargin As Single = ev.MarginBounds.Left<br />
        Dim topMargin As Single = ev.MarginBounds.Top<br />
        Dim line As String = Nothing<br />
<br />
        ' Calculate the number of lines per page.<br />
        linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)<br />
<br />
        ' Iterate over the file, printing each line.<br />
        While count < linesPerPage<br />
            line = streamToPrint.ReadLine()<br />
            If line Is Nothing Then<br />
                Exit While<br />
            End If<br />
            yPos = topMargin + count * printFont.GetHeight(ev.Graphics)<br />
            ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, _<br />
                yPos, New StringFormat())<br />
            count += 1<br />
        End While<br />
<br />
        ' If more lines exist, print another page.<br />
        If Not (line Is Nothing) Then<br />
            ev.HasMorePages = True<br />
        Else<br />
            ev.HasMorePages = False<br />
        End If<br />
    End Sub<br />
------------------------------------------<br />
    ' Print the file.<br />
    Public Sub Printing()<br />
        Try<br />
            streamToPrint = New StreamReader(app_path & "\data.txt")<br />
            Try<br />
                printFont = New Font("Arial", 10)<br />
                Dim pd As New PrintDocument()<br />
                AddHandler pd.PrintPage, AddressOf pd_PrintPage<br />
                ' Print the document.<br />
                pd.Print()<br />
            Finally<br />
                streamToPrint.Close()<br />
            End Try<br />
        Catch ex As Exception<br />
            MessageBox.Show(ex.Message)<br />
        End Try<br />
    End Sub 'Printing    <br />
<br />
    ' This is the main entry point for the application.<br />
    Public Shared Sub Main()<br />
        Dim args() As String = System.Environment.GetCommandLineArgs()<br />
        Dim sampleName As String = args(0)<br />
        If args.Length <> 1 Then<br />
            Console.WriteLine("Usage: " & sampleName & " <file path>")<br />
            Return<br />
        End If<br />
        filePath = args(0)<br />
    End Sub<br />


add to your click event this:

Private Sub btnprint_click(byval sender as object, byval e as system.eventargs) handles btnprint.click<br />
printing()<br />
End Sub

Questionaccessing word document Pin
vimal_yet29-Jan-07 22:10
vimal_yet29-Jan-07 22:10 
AnswerRe: accessing word document Pin
Vasudevan Deepak Kumar29-Jan-07 22:28
Vasudevan Deepak Kumar29-Jan-07 22:28 
QuestionRe: accessing word document Pin
vimal_yet29-Jan-07 22:52
vimal_yet29-Jan-07 22:52 
QuestionExcel file (Read and Write) Pin
naramis29-Jan-07 21:54
naramis29-Jan-07 21:54 
AnswerRe: Excel file (Read and Write) Pin
Christian Graus29-Jan-07 21:57
protectorChristian Graus29-Jan-07 21:57 
AnswerRe: Excel file (Read and Write) Pin
Vasudevan Deepak Kumar29-Jan-07 22:29
Vasudevan Deepak Kumar29-Jan-07 22:29 
Questiondelete, copy etc does not work with windows form ? Pin
porsti29-Jan-07 21:40
porsti29-Jan-07 21:40 
AnswerRe: delete, copy etc does not work with windows form ? Pin
Christian Graus29-Jan-07 21:57
protectorChristian Graus29-Jan-07 21:57 
GeneralRe: delete, copy etc does not work with windows form ? Pin
porsti29-Jan-07 22:02
porsti29-Jan-07 22:02 
QuestionHow to get ipv6 address on local machine? Pin
Teeyai29-Jan-07 20:43
Teeyai29-Jan-07 20:43 
AnswerRe: How to get ipv6 address on local machine? Pin
shakti538529-Jan-07 21:55
shakti538529-Jan-07 21:55 
AnswerRe: How to get ipv6 address on local machine? Pin
Teeyai30-Jan-07 5:25
Teeyai30-Jan-07 5:25 
QuestionDataGridSorting Pin
vin107029-Jan-07 19:37
vin107029-Jan-07 19:37 
QuestionHow to Access Current Index Of Combobox in Datagridview Pin
priya_p23329-Jan-07 19:19
priya_p23329-Jan-07 19:19 
AnswerRe: How to Access Current Index Of Combobox in Datagridview Pin
Nilesh Hapse29-Jan-07 20:27
Nilesh Hapse29-Jan-07 20:27 
GeneralRe: How to Access Current Index Of Combobox in Datagridview Pin
priya_p23329-Jan-07 20:38
priya_p23329-Jan-07 20:38 
GeneralRe: How to Access Current Index Of Combobox in Datagridview Pin
Nilesh Hapse29-Jan-07 22:30
Nilesh Hapse29-Jan-07 22:30 

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.