alina.nazchowdhury 0 Newbie Poster

I get lots of error in my program like: Warning 1 WithEvents variable 'Close' conflicts with sub 'Close' in the base class 'Form' and should be declared 'Shadows'. C:\Documents and Settings\Alina\My Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\Form1.Designer.vb 321 23 WindowsApplication1
Error 2 Expression is not a method. C:\Documents and Settings\Alina\My Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 63 9 WindowsApplication1
Error 3 Property access must assign to the property or use its value. C:\Documents and Settings\Alina\My Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\Form1.vb 141 9 WindowsApplication1
Please somebody help me, i can not understand why.
Here is the code:

Public Class Picture_Viewer

  Public ImageNum As Integer


Private Sub opt_image1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opt_image1.CheckedChanged
    mypic.Image = My.Resources.img1
End Sub

Private Sub opt_image2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opt_image2.CheckedChanged
    mypic.Image = My.Resources.img2
End Sub

Private Sub opt_image3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opt_image3.CheckedChanged
    mypic.Image = My.Resources.img3
End Sub

Private Sub opt_image4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opt_image4.CheckedChanged
    mypic.Image = My.Resources.img4
End Sub

Private Sub opt_image5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opt_image5.CheckedChanged
    mypic.Image = My.Resources.img5
End Sub
Private Sub opt_image6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opt_image6.CheckedChanged
    mypic.Image = My.Resources.img6
End Sub
Private Sub opt_image7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    mypic.Image = My.Resources.img7
End Sub

Private Sub opt_image8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opt_image8.CheckedChanged
    mypic.Image = My.Resources.img8
End Sub

Private Sub opt_image9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles opt_image9.CheckedChanged
    mypic.Image = My.Resources.img9
End Sub

Private Sub Picture_Viewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    mypic.Image = My.Resources.img3
    opt_image3.Checked = True
End Sub

Private Sub Clear_picture_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Clear_picture.Click
    mypic.Image = Nothing
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    If (ColorDialog1.ShowDialog() = DialogResult.OK) Then
        Me.BackColor = ColorDialog1.Color
    End If

End Sub


Private Sub Back_color_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Back_color.Click
    If (ColorDialog1.ShowDialog() = DialogResult.OK) Then
        mypic.BackColor = ColorDialog1.Color
    End If

End Sub

Private Sub Previous_pic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Previous_pic.Click
    ImageNum(-1)
    If ImageNum < 1 Then ImageNum = 9 ' decreases the numbers

    Select Case ImageNum
        Case 1
            mypic.Image = My.Resources.img1
            opt_image1.Checked = True
        Case 2
            mypic.Image = My.Resources.img2
            opt_image2.Checked = True
        Case 3
            mypic.Image = My.Resources.img3
            opt_image3.Checked = True
        Case 4
            mypic.Image = My.Resources.img4
            opt_image4.Checked = True
        Case 5
            mypic.Image = My.Resources.img5
            opt_image5.Checked = True
        Case 6
            mypic.Image = My.Resources.img6
            opt_image6.Checked = True
        Case 7
            mypic.Image = My.Resources.img7
            opt_image7.Checked = True
        Case 8
            mypic.Image = My.Resources.img8
            opt_image8.Checked = True
        Case 9
            mypic.Image = My.Resources.img9
            opt_image9.Checked = True
    End Select
End Sub

Private Sub Next_pic_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Next_pic.Click
    ImageNum(+1)
    If ImageNum > 1 Then ImageNum = 9 ' increases the numbers

    Select Case ImageNum
        Case 1
            mypic.Image = My.Resources.img1
            opt_image1.Checked = True
        Case 2
            mypic.Image = My.Resources.img2
            opt_image2.Checked = True
        Case 3
            mypic.Image = My.Resources.img3
            opt_image3.Checked = True
        Case 4
            mypic.Image = My.Resources.img4
            opt_image4.Checked = True
        Case 5
            mypic.Image = My.Resources.img5
            opt_image5.Checked = True
        Case 6
            mypic.Image = My.Resources.img6
            opt_image6.Checked = True
        Case 7
            mypic.Image = My.Resources.img7
            opt_image7.Checked = True
        Case 8
            mypic.Image = My.Resources.img8
            opt_image8.Checked = True
        Case 9
            mypic.Image = My.Resources.img9
            opt_image9.Checked = True
    End Select
End Sub


Private Sub Select_image_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Select_image.Click
    If (OpenFileDialog1.ShowDialog() = DialogResult.OK) Then

        mypic.Load(OpenFileDialog1.FileName)
    End If
End Sub

Private Sub Close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Close.Click
    Close()
End Sub


Private Sub Stretch_image_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chk_slide_show.CheckedChanged
    If (chk_slide_show.Checked) Then
        mypic.SizeMode = PictureBoxSizeMode.StretchImage
    Else
        mypic.SizeMode = PictureBoxSizeMode.Normal
    End If
End Sub


Private Sub Slide_show_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Slide_show.CheckedChanged
    If Slide_show.Checked = True Then
        Timer1.Enabled = True
    Else
        Timer1.Enabled = False
    End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Call Next_pic_Click(sender, e)
End Sub

End Class

Dani AI

Generated

Several distinct problems in 's project explain the build warnings and runtime surprises: a control name colliding with a Form method, attempts to "call" an Integer as if it were a procedure, and a few event handlers that are not actually wired. Each of those produces the messages seen; fixing them cleanly will remove the warnings and make the slideshow logic behave predictably.

The fastest, safest fix for the WithEvents/name collision is to rename the control that uses the reserved name (for example, change the button named "Close" to btnClose) using the Properties window in the designer. Renaming through the designer updates Designer.vb and event wiring automatically; avoid manual edits to Designer.vb. Hiding the base member with the Shadows modifier is possible but not recommended for UI controls — it just suppresses the warning rather than resolving the root conflict (Shadows (VB)).

The "Expression is not a method" / "Property access must assign..." errors come from using parentheses as if calling a procedure (for example: ImageNum(+1) or ImageNum(-1)). Replace those with arithmetic assignments and correct wrap-around logic. Examples:

ImageNum -= 1
If ImageNum < 1 Then ImageNum = 9
ImageNum += 1
If ImageNum > 9 Then ImageNum = 1

A compact alternative using modular arithmetic (where delta is +1 or -1):

ImageNum = ((ImageNum - 1 + delta) Mod 9) + 1

Finally, confirm every event handler has a matching Handles clause or is connected in the designer (add Handles opt_image7.CheckedChanged if a handler is missing). Refactor repeated Select/Case blocks into a single ShowImageByIndex(index) helper that both the Next/Previous logic and the Timer tick call; avoid calling button click handlers directly from the timer. After these changes, rebuild the project and the earlier compiler errors should be resolved. For details on wiring handlers, see the Handles-clause guidance: .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.