I am creating a very simple drawing application as an assignment for a VB.NET class. The app draws a freehand line with the mouse inside a PictureBox and allows change of color and linewidth. It works fine except when I change the line width using a combo box, then it throws an out of memory exception. Bizarre thing is. . . it only seems to throw the exception when I change the line from smaller (1 px) to larger (5 px). It doesn't throw the exception if I go from large to small!!!!
I have caught the exception on this line:
e.Graphics.DrawPath(PenDown, PenPath)
PenDown is my pen class object that is created by:
Dim PenDown As New Pen(PenColor, PenWidth)
PenPath is created with PenPath.AddLine(e.X, e.Y, e.X, e.Y)
The PenWidth property of PenDown is being assigned from a combo box with the statement:
PenWidth = CSng(PenSize.SelectedIndex + 1)
Pensize is the name of the combobox. +1 because the SelectedIndex starts at 0. The CSng() explicitly converts the return from the combobox to SINGLE data type which is what the Pen class requires. The conversion is not necessary and it is done implicitly but it's one of the many steps I have taken to solve my problem.
I have taken many steps to try to solve this issue including consulting a professional VB.Net coder I found on CraigsList. Anyone?????
Many thanks.
Graham
I have caught the exception on this line:
e.Graphics.DrawPath(PenDown, PenPath)
PenDown is my pen class object that is created by:
Dim PenDown As New Pen(PenColor, PenWidth)
PenPath is created with PenPath.AddLine(e.X, e.Y, e.X, e.Y)
The PenWidth property of PenDown is being assigned from a combo box with the statement:
PenWidth = CSng(PenSize.SelectedIndex + 1)
Pensize is the name of the combobox. +1 because the SelectedIndex starts at 0. The CSng() explicitly converts the return from the combobox to SINGLE data type which is what the Pen class requires. The conversion is not necessary and it is done implicitly but it's one of the many steps I have taken to solve my problem.
I have taken many steps to try to solve this issue including consulting a professional VB.Net coder I found on CraigsList. Anyone?????
Many thanks.
Graham