Solved

Strange drawstring problem with numbers

Posted on 2009-07-11
8
336 Views
Last Modified: 2012-05-07
I have noticed that when I use drawstring to only print numbers, it just prints nothing. However if I put a letter in the string, it prints.

So, "12345" will not work, however
"a12345" will work.

Any help will be much appreciated!
Dim g As Graphics = e.Graphics
 

g.PageUnit = GraphicsUnit.Millimeter
 

g.DrawString("12345", myFont, getBrush(strColor), X, Y)

Open in new window

0
Comment
Question by:syinner
  • 4
  • 3
8 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 24830194
comment out this line and it will work:
'g.PageUnit = GraphicsUnit.Millimeter
0
 

Author Comment

by:syinner
ID: 24830227
unfortunately that didn't work, and if it did, that would be crazy setting to remove!

how does changing the page unit allow me to print numbers?
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 24830246
can you try this code as is:

    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim myFont As Font = Me.Font
        Dim x As Integer = 10
        Dim y As Integer = 10
        Dim g As Graphics = e.Graphics

        g.PageUnit = GraphicsUnit.Display

        g.DrawString("12345", myFont, Brushes.Black, x, y)

    End Sub

If it is working like it is working for me, you may have a problem with your Font, your Brush, or your location.
0
 

Author Comment

by:syinner
ID: 24830278
I tried changing to display but the same problem.

I don't believe its a problem with the location, brush etc because I add a letter into the string and it works with the same settings.

I still don't see how changing the display unit will stop numbers from being printed? when I can print letters, special characters and line breaks.

i have used the same unit to print lines and boxes.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 69

Expert Comment

by:Éric Moreau
ID: 24830292
I can't help you more, it is working on my side.
0
 

Author Comment

by:syinner
ID: 24830305
If I wanted to change the PageUnit permanently, it would be a big problem as its used allot.  

Anyone have any ideas why I am facing this strange problem with drawstring and numbers bearing in mind that it works fine for letters?
0
 
LVL 1

Expert Comment

by:nailgg
ID: 24830497
Hi syinner;

Dim g As Graphics = e.Graphics

Dim MyString as String
 

g.PageUnit = GraphicsUnit.Millimeter

MyString = "12345"
 

g.DrawString(MyString, myFont, getBrush(strColor), X, Y)

Open in new window

0
 

Accepted Solution

by:
syinner earned 0 total points
ID: 24830519
Found the problem...I am using PaperlessPrinter to do my testing as this is in a vmware image... it was just not printing the line

Linked up my actual printer and it printed it!!!

Any suggestions on replacing this driver...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now