none
BC30516 error PLEASE HELP RRS feed

  • Question

  • Imports System.Drawing

    Public Class PaintApp
    Dim draw As Boolean
    Dim Color As Color = Color.Black
    Dim DrawSize As Integer = 4

    Dim bmp As Bitmap


    Private Sub PaintApp_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    'Brush Size
    SizeBox.SelectedIndex = 2

    'Bitmap saves
    bmp = New Bitmap(DrawBox.Width, DrawBox.Height)
    DrawBox.Image = bmp

    End Sub

    Private Sub PaintBrush(X As Integer, Y As Integer)
    Using g As Graphics = Graphics.FromImage(DrawBox.Image)
    g.FillRectangle(New SolidBrush(Color), New Rectangle(X, Y, DrawSize, DrawSize))
    End Using

    DrawBox.Refresh()
    End Sub



    Private Sub DrawBox_MouseDown(sender As Object, e As MouseEventArgs) Handles DrawBox.MouseDown
    draw = True
    'first pixel
    PaintBrush(e.X, e.Y)
    End Sub

    Private Sub DrawBox_MouseMove(sender As Object, e As MouseEventArgs) Handles DrawBox.MouseMove
    If draw = True Then
    PaintBrush(e.X, e.Y)
    End If
    End Sub

    Private Sub DrawBox_MouseUp(sender As Object, e As MouseEventArgs) Handles DrawBox.MouseUp
    draw = False
    End Sub

    Private Sub ClearButt_Click(sender As Object, e As EventArgs) Handles ClearButt.Click
    MessageBox.Show("your undsaved picture gonna be deleted")
    bmp = New Bitmap(DrawBox.Width, DrawBox.Height)
    DrawBox.Image = bmp

    End Sub

    Private Sub SizeBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles SizeBox.SelectedIndexChanged
    DrawSize = SizeBox.SelectedItem
    End Sub

    Private Sub ColorButt_Click(sender As Object, e As EventArgs) Handles ColorButt.Click
    If ColorDialog1.ShowDialog() = DialogResult.OK Then
    Color = ColorDialog1.Color
    End If
    End Sub

    Private Sub SaveButt_Click(sender As Object, e As EventArgs) Handles SaveButt.Click

                  ' error down

    DrawBox.DrawToBitmap(bmp, New Rectangle(0.0, DrawBox.Width, DrawBox.Height)) ' error on this line

    bmp.Save("Test1.png", Imaging.ImageFormat.Png)
    bmp = New Bitmap(DrawBox.Width, DrawBox.Height)
    End Sub
    End Class



    • Edited by kerbosos Wednesday, November 8, 2017 12:51 AM
    Wednesday, November 8, 2017 12:48 AM

All replies

  • Which line of code creates this error?  The full error message indicates the problem.  For instance, it might be that you are passing incorrect parameters to a constructor.  If you can identify the line of code involved you can see where there is a constructor being called, then you can look up the definition for the object you are constructing and determine what the correct parameters are.  But you have to start from the code that actually caused the error, and the exact error message.

    Wednesday, November 8, 2017 12:53 AM