Relationship between printer.Currentx in VB6 and PointF(x,y) in VB .Net

ben_ng

Member
Joined
Sep 13, 2007
Messages
18
Location
Singapore
Programming Experience
1-3
Hi,
I am quite new to VB and I am currently trying to convert a VB6 project into VB .Net.

I have encountered Printer.CurrentX(CoordX) in VB6 and have converted it using args.Graphics.DrawString(x.m_txtTextToPrint, myFont, drawBrush, drawPoint)
Dim drawPoint As New PointF(x.iCoordX, x.iCoordY)

May I know what is the relationship between CoordX and iCoordX?
How do I convert CoordX to iCoordX, so that I can print what I want to print at the same position?
Thanks!
 
My code in VB6 :
VB.NET:
    Printer.FontSize = 10
    Printer.FontName = "Arial"
    Printer.FontBold = true
    Printer.CurrentX = 3900
    Printer.CurrentY = 1900
    Printer.Print "Printing Test"

My code in VB .Net:
VB.NET:
Imports System.Drawing.Printing
Imports System.Windows.Forms
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Print As New myPrinter
        Print.prt("Printing Test", True, 3900, 1900, "Arial", 10)
    End Sub
End Class
Public Class myPrinter
    Friend TextToBePrinted As String
    Friend ssFontName As String
    Friend bbBold As Boolean
    Friend iiFontSize As Integer
    Friend cCoordX As Single
    Friend cCoordY As Single
    Public Sub prt(ByRef txtPrint As String, ByRef bBold As Boolean, ByRef CoordX As Short, _
ByRef CoordY As Short, Optional ByRef sFontName As String = "", Optional ByRef iFontSize As Short = 0)
        TextToBePrinted = txtPrint
                ssFontName = sFontName
        bbBold = bBold
                iiFontSize = iFontSize
                cCoordX = CoordX
        cCoordY = CoordY
                Dim prn As New Printing.PrintDocument
        Using (prn)
            AddHandler prn.PrintPage, AddressOf Me.PrintPageHandler
                        prn.Print()
            RemoveHandler prn.PrintPage, AddressOf Me.PrintPageHandler
                End Using
    End Sub
    Private Sub PrintPageHandler(ByVal sender As Object, ByVal args As Printing.PrintPageEventArgs)
        Dim myFont As New Font(ssFontName, iiFontSize)
                Dim drawBrush As New SolidBrush(Color.Black)
                Dim drawPoint As New PointF(cCoordX, cCoordY)
        Dim drawFormat As New StringFormat
        drawFormat.FormatFlags = StringFormatFlags.DirectionVertical
                args.Graphics.DrawString(TextToBePrinted, myFont, drawBrush, drawPoint)
    End Sub
End Class

The '3900' in CurrentX and the '3900' in PointF.X is definitely different right? Anyone knows that relationship/conversion formula between the 2?
Thanks!
 

Latest posts

Back
Top