none
Null Reference Exception was unhandled RRS feed

  • Question

  • Hi,

    I have found an error "Null Reference Exception was unhanded" (during run the application to print a one paper.)

    as shown in the attached photo,

    The code as below.

    Can any one provide me of how to overcome that error?

    b = Xmax - Xmin t = Ymax - Ymin Dim Strb As String = CInt(b) & " x " & CInt(t) & " mm" Dim Brush As New SolidBrush(Color.Black) Dim textsizeb As SizeF Dim XQQb As Integer

    Dim DrawFont As New Font("Verdana", 10, FontStyle.Regular) textsizeb = G.MeasureString(Strb, DrawFont) XQQb = 10 + CInt((200 - CInt(textsizeb.Width)) / 2)



    Hany Metry


    • Edited by Hany Metry Sunday, November 17, 2019 4:37 PM add in the code Dim DrawFont As New Font("Verdana", 10, FontStyle.Regular)
    Sunday, November 17, 2019 4:30 PM

Answers

  • Hi,
    where you get or assign the variable "G"?

    --
    Best Regards / Viele Grüße
    Peter Fleischer (former MVP for Developer Technologies)
    Homepage, Tipps, Tricks

    • Marked as answer by Hany Metry Sunday, November 17, 2019 4:49 PM
    Sunday, November 17, 2019 4:37 PM
  • Hi,
    where you get or assign the variable "G"?

    --
    Best Regards / Viele Grüße
    Peter Fleischer (former MVP for Developer Technologies)
    Homepage, Tipps, Tricks

    When I replace G by G1 and define G1 at the top of Sub as below, my problem is solved

    Thank you

    Dim G1 As Graphics = e.Graphics

    Kind Regards,


    Hany Metry

    • Marked as answer by Hany Metry Sunday, November 17, 2019 4:49 PM
    Sunday, November 17, 2019 4:49 PM

All replies

  • Hi,
    where you get or assign the variable "G"?

    --
    Best Regards / Viele Grüße
    Peter Fleischer (former MVP for Developer Technologies)
    Homepage, Tipps, Tricks

    • Marked as answer by Hany Metry Sunday, November 17, 2019 4:49 PM
    Sunday, November 17, 2019 4:37 PM
  • Hi,
    where you get or assign the variable "G"?

    --
    Best Regards / Viele Grüße
    Peter Fleischer (former MVP for Developer Technologies)
    Homepage, Tipps, Tricks

    Variable G is defined in the module as friend

    Friend G As Graphics

    Kind Regards,

     

    Hany Metry

    Sunday, November 17, 2019 4:41 PM
  • Hi,
    where you get or assign the variable "G"?

    --
    Best Regards / Viele Grüße
    Peter Fleischer (former MVP for Developer Technologies)
    Homepage, Tipps, Tricks

    When I replace G by G1 and define G1 at the top of Sub as below, my problem is solved

    Thank you

    Dim G1 As Graphics = e.Graphics

    Kind Regards,


    Hany Metry

    • Marked as answer by Hany Metry Sunday, November 17, 2019 4:49 PM
    Sunday, November 17, 2019 4:49 PM