invalid parameter

Can anyone tell me why this throws a system.argumentexception:Invalid parameter


Imports System.Drawing

Public Class form1

 

Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

'This call is required by the Windows Form Designer.

InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

'Required by the Windows Form Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer

'It can be modified using the Windows Form Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

'

'mypen

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(292, 266)

Me.Name = "mypen"

Me.Text = "Form1"

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)

Dim g As Graphics = e.Graphics

Dim stripe As Image = New Bitmap("e:\colorbars.jpg")

Dim b1 As TextureBrush = New TextureBrush(stripe)

Dim b2 As SolidBrush = New SolidBrush(Color.Aquamarine)

Dim p1 As Pen

p1 = New Pen(b1, 10)

g.DrawLine(p1, 20, 20, Me.Width - 40, Me.Height - 40)

System.Threading.Thread.CurrentThread.Sleep(1000)

p1 = New Pen(b2, 10)

g.DrawLine(p1, 20, 20, Me.Width - 40, Me.Height - 40)

System.Threading.Thread.CurrentThread.Sleep(1000)

p1 = New Pen(Color.BlanchedAlmond, 10)

g.DrawLine(p1, 20, 20, Me.Width - 40, Me.Height - 40)

System.Threading.Thread.CurrentThread.Sleep(1000)

b1.Dispose()

b2.Dispose()

p1.Dispose()

End Sub

End Class



Answer this question

invalid parameter

  • shoagMSFT

    It was thrown at {Public Class Form1} line
  • Mostafa Omar

    03
    No accessible 'Main' method with an appropriate signature was found in 'MyPen.main_sub'.
    This is what I`m getting.

  • Mareen Philip MSFT

    I am getting this message:No accessible 'Main' method with an appropriate signature was found in 'MyPen.main_sub'.

  • Amit Paka

    If this is your startup form, instead of trying to build and run the code...step into using the debugger. This should show you where the actual error is comming from....

    If not your start-up where is the form being called from

  • LMcFarlin

    What version 03 or 05



  • Chris Duxbury

    What is "stripe" in this line...
    Is it a string....needs quotes
    Where is it defined



    Dim b1 As TextureBrush = New TextureBrush(stripe)

     



  • Witi

    It says that there is no sub main and I have tried to make one ,but I`ve had no success.I`ve search my books and the help section on vs and can`t get anything that help me out.
    I am real new to vb and just feeling my way through, so it is probably something simple.
    Any help will be greatly appreciated.

  • bodalal

    from the solution explorer...right click on your project and go to properties...

     

    change the start-up object from sub main to your form...



  • invalid display name

    stripes was dimmed as image a little earlier in the code.
  • zz1

     rgerbig wrote:
    Hi,

    at which line is this exception thrown that makes it lots easier to find you bug.

    It was thrown at the {Public Class form1} line.

  • bear007

    Hi,

    at which line is this exception thrown that makes it lots easier to find you bug.


  • Aleborg

    on the debugger toolbar keep stepping into...or use 'F11'

    untill you get to your error....



  • Hannodb

     Public Sub New() is whats lit up after stepping into the debugger


  • djchapin

    The startup object is already form1
  • invalid parameter