locked
code help RRS feed

  • Question

  • this code is bringing up  4 errors
    1: method arguments must be closed in parentheses
    2: name bound is not declared
    3: comma, ) or a valid exspression contitnuation exspected
    4: forma is not a member of system.drawing.imaging.pixelformat

    the code is for a screen capture

    it also doesent look quite right....  i got it from a vb site.....
    i think its missing spacing any help?

    If CheckBox1.Checked = CheckBox2.Checked = True Then MsgBox("Error") Else If CheckBox1.Checked = True Then Me.Hide() bound = Screen.PrimaryScreen.Bounds screenshot = New System.Drawing.Bitmap(bound.Width, bound.Height, System.Drawing.Imaging.PixelFormat.Forma t32bppArgb) graph = Graphics.FromImage(screenshot) graph.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation.SourceCopy) Form2.PictureBox1.Image = screenshot Form2.Show() Me.Show() Else If TextBox1.Text = "" Then MsgBox("Invalid information") Else If TextBox2.Text = "" Then MsgBox("Invalid information") Else If TextBox1.Text + TextBox2.Text = "" Then MsgBox("Invalid information") Else Me.Hide() Form2.Hide() Form2.PictureBox1.Width = TextBox1.Text Form2.PictureBox1.Height = TextBox2.Text bound = Screen.PrimaryScreen.Bounds screenshot = New System.Drawing.Bitmap(bound.Width, bound.Height, System.Drawing.Imaging.PixelFormat.Forma t32bppArgb) graph = Graphics.FromImage(screenshot) graph.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation.SourceCopy) Form2.PictureBox1.Image = screenshot Form2.Show() Me.Show() End If End If End If End If End If



    I like..... Understandable Answers 1 2 3 4 5 - - - - - Rate yourself And Have A Kitkat 5 5 5 5 5
    Saturday, October 3, 2009 10:51 AM

Answers

  • Dear Dark ,
    Please format your code using "Insert Code Block " near "HTML " button in the message menu.

    As a preliminary solution
    creenshot = New System.Drawing.Bitmap(bound.Width,bound.Height, System.Drawing.Imaging.PixelFormat.Forma t32bppArgb)
    The bolded argument should be

    Format32bppArgb
    So remove the space of the enumerated type.






    Waleed El-Badry ,Teaching Assistant, Faculty of Engineering , Misr University for Science & Technology
    • Marked as answer by Darkhalodude Saturday, October 3, 2009 11:19 AM
    Saturday, October 3, 2009 11:01 AM

All replies

  • Dear Dark ,
    Please format your code using "Insert Code Block " near "HTML " button in the message menu.

    As a preliminary solution
    creenshot = New System.Drawing.Bitmap(bound.Width,bound.Height, System.Drawing.Imaging.PixelFormat.Forma t32bppArgb)
    The bolded argument should be

    Format32bppArgb
    So remove the space of the enumerated type.






    Waleed El-Badry ,Teaching Assistant, Faculty of Engineering , Misr University for Science & Technology
    • Marked as answer by Darkhalodude Saturday, October 3, 2009 11:19 AM
    Saturday, October 3, 2009 11:01 AM
  • like....

    If CheckBox1.Checked = CheckBox2.Checked = True Then MsgBox("Error") Else If CheckBox1.Checked = True Then Me.Hide() bound = Screen.PrimaryScreen.Bounds screenshot = New System.Drawing.Bitmap(bound.Width, bound.Height, System.Drawing.Imaging.PixelFormat.Forma t32bppArgb) graph = Graphics.FromImage(screenshot) graph.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation.SourceCopy) Form2.PictureBox1.Image = screenshot Form2.Show() Me.Show() Else If TextBox1.Text = "" Then MsgBox("Invalid information") Else If TextBox2.Text = "" Then MsgBox("Invalid information") Else If TextBox1.Text + TextBox2.Text = "" Then MsgBox("Invalid information") Else Me.Hide() Form2.Hide() Form2.PictureBox1.Width = TextBox1.Text Form2.PictureBox1.Height = TextBox2.Text bound = Screen.PrimaryScreen.Bounds screenshot = New System.Drawing.Bitmap(bound.Width, bound.Height, System.Drawing.Imaging.PixelFormat.Forma t32bppArgb) graph = Graphics.FromImage(screenshot) graph.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation.SourceCopy) Form2.PictureBox1.Image = screenshot Form2.Show() Me.Show() End If End If End If End If End If

    I like..... Understandable Answers 1 2 3 4 5 - - - - - Rate yourself And Have A Kitkat 5 5 5 5 5
    Saturday, October 3, 2009 11:09 AM
  • ive changes the code 1 error now :) ty, im only 14, im trying to learn a progamming language

    1: end of statement exspected:

    theres a big chunk on 1 row is it supposed to be like this?

    If CheckBox1.Checked = CheckBox2.Checked = True Then
    
            End If
            MsgBox("Error") Else If CheckBox1.Checked = True Then Me.Hide() bound = Screen.PrimaryScreen.Bounds screenshot = New System.Drawing.Bitmap(bound.Width, bound.Height, System.Drawing.Imaging.PixelFormat.FormaFormat32bppArgb) graph = Graphics.FromImage(screenshot) graph.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation.SourceCopy) Form2.PictureBox1.Image = screenshot Form2.Show() Me.Show() Else If TextBox1.Text = "" Then MsgBox("Invalid information") Else If TextBox2.Text = "" Then MsgBox("Invalid information") Else If TextBox1.Text + TextBox2.Text = "" Then MsgBox("Invalid information") Else Me.Hide() Form2.Hide() Form2.PictureBox1.Width = TextBox1.Text Form2.PictureBox1.Height = TextBox2.Text bound = Screen.PrimaryScreen.Bounds screenshot = New System.Drawing.Bitmap(bound.Width, bound.Height, System.Drawing.Imaging.PixelFormat.Forma t32bppArgb) graph = Graphics.FromImage(screenshot) graph.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation.SourceCopy) Form2.PictureBox1.Image = screenshot Form2.Show() Me.Show() End If End If End If End If End If
    
    
        End Sub


    I like..... Understandable Answers 1 2 3 4 5 - - - - - Rate yourself And Have A Kitkat 5 5 5 5 5
    Saturday, October 3, 2009 11:13 AM
  • No Dark, it is considered a bad practice to even if the compiler can compile it this way. As you can see it makes the code less readable and hence difficult for debugging.


            Dim screenshot
            Dim graph
            If CheckBox1.Checked = CheckBox2.Checked = True Then
                MsgBox("Error")
            ElseIf CheckBox1.Checked = True Then
                Me.Hide()
                Dim bound = Screen.PrimaryScreen.Bounds
                screenshot = New System.Drawing.Bitmap(bound.Width, bound.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                graph = Graphics.FromImage(screenshot)
                graph.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation.SourceCopy)
                Form2.PictureBox1.Image = screenshot
                Form2.Show()
                Me.Show()
            ElseIf TextBox1.Text = "" Then
                MsgBox("Invalid information")
            ElseIf TextBox2.Text = "" Then
                MsgBox("Invalid information")
            ElseIf TextBox1.Text + TextBox2.Text = "" Then
                MsgBox("Invalid information")
            Else
                Me.Hide()
                Form2.Hide()
                Form2.PictureBox1.Width = TextBox1.Text
                Form2.PictureBox1.Height = TextBox2.Text
                Dim bound = Screen.PrimaryScreen.Bounds
                screenshot = New System.Drawing.Bitmap(bound.Width, bound.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
                graph = Graphics.FromImage(screenshot)
                graph.CopyFromScreen(bound.X, bound.Y, 0, 0, bound.Size, CopyPixelOperation.SourceCopy)
                Form2.PictureBox1.Image = screenshot
                Form2.Show()
                Me.Show()
            End If


    Waleed El-Badry ,Teaching Assistant, Faculty of Engineering , Misr University for Science & Technology
    Saturday, October 3, 2009 12:53 PM