Solved

Strange drawstring problem with numbers

Posted on 2009-07-11
8
333 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

758 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

21 Experts available now in Live!

Get 1:1 Help Now