EDN Admin
Well-known member
I am attempting to get through the Create a Picture Viewer in Visual Basic. Below is the code provided in the tutorial: It appears that the code is for C# not VB
There are three (3) sections in this email. All sections is devided by =========================================
Below is the code that is provided.
private void clearButton_Click(object sender, EventArgs e)<br/>
{<br/>
// Clear the picture.<br/>
pictureBox1.Image = null;<br/>
}
private void backgroundButton_Click(object sender, EventArgs e)<br/>
{<br/>
// Show the color dialog box. If the user clicks OK, change the<br/>
// PictureBox controls background to the color the user chose.<br/>
if (colorDialog1.ShowDialog() == DialogResult.OK)<br/>
pictureBox1.BackColor = colorDialog1.Color;<br/>
}
private void closeButton_Click(object sender, EventArgs e)<br/>
{<br/>
// Close the form.<br/>
this.Close();<br/>
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)<br/>
{<br/>
// If the user selects the Stretch check box, <br/>
// change the PictureBoxs<br/>
// SizeMode property to "Stretch". If the user clears <br/>
// the check box, change it to "Normal".<br/>
if (checkBox1.Checked)<br/>
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;<br/>
else<br/>
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;<br/>
}
Below is the Code when I get to Step 11 Run Your Program and Try Other Features<br/>
==================================================================================================<br/>
Public Class Form1
Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged<br/>
If (CheckBox1.Checked) Then<br/>
PicureBox1.SizeMode = PictureBoxSizeMode.StretchImage<br/>
Else<br/>
PictureBox1.SizeMode = PictureBoxSizeMode.Normal
End If<br/>
End Sub
Private Sub FlowLayoutPanel1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles FlowLayoutPanel1.Paint
End Sub
Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TableLayoutPanel1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles TableLayoutPanel1.Paint
End Sub
Private Sub showButton_Click(sender As System.Object, e As System.EventArgs) Handles showButton.Click
<br/>
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then<br/>
PictureBox1.Load(OpenFileDialog1.FileName)<br/>
End If
<br/>
End Sub
Private Sub closeButton_Click(sender As System.Object, e As System.EventArgs) Handles closeButton.Click<br/>
Close()
End Sub
Private Sub backgroundButton_Click(sender As System.Object, e As System.EventArgs) Handles backgroundButton.Click<br/>
If (ColorDialog1.ShowDialog() = DialogResult.OK) Then<br/>
PictureBox1.BackColor = ColorDialog1.Color
End If
<br/>
End Sub
Private Sub clearButton_Click(sender As System.Object, e As System.EventArgs) Handles clearButton.Click<br/>
PictureBox1.Image = DBNull
End Sub
Private Sub OpenFileDialog1_FileOk(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
End Sub
Private Function DBNull() As Image<br/>
Throw New NotImplementedException<br/>
End Function
Private Function PicureBox1() As Object<br/>
Throw New NotImplementedException<br/>
End Function
End Class
When I click the START Debugging toolbar button I get the following errors.<br/>
I have no idea what to do at this point. I need help.
===================================================================================================<br/>
System.InvalidOperationException was unhandled<br/>
Message=An error occurred creating the form. See Exception.InnerException for details. The error is: The method or operation is not implemented.<br/>
Source=WindowsApplication1<br/>
StackTrace:<br/>
at WindowsApplication1.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190<br/>
at WindowsApplication1.My.MyProject.MyForms.get_Form1()<br/>
at WindowsApplication1.My.MyApplication.OnCreateMainForm() in Cocuments and SettingsEdmy documentsvisual studio 2010ProjectsWindowsApplication1WindowsApplication1My ProjectApplication.Designer.vb:line 35<br/>
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()<br/>
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()<br/>
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)<br/>
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81<br/>
InnerException: System.NotImplementedException<br/>
Message=The method or operation is not implemented.<br/>
Source=WindowsApplication1<br/>
StackTrace:<br/>
at WindowsApplication1.Form1.PicureBox1() in Cocuments and SettingsEdmy documentsvisual studio 2010ProjectsWindowsApplication1WindowsApplication1Form1.vb:line 68<br/>
at WindowsApplication1.Form1.CheckBox1_CheckedChanged(Object sender, EventArgs e) in Cocuments and SettingsEdmy documentsvisual studio 2010ProjectsWindowsApplication1WindowsApplication1Form1.vb:line
5<br/>
at System.Windows.Forms.CheckBox.OnCheckedChanged(EventArgs e)<br/>
at System.Windows.Forms.CheckBox.set_CheckState(CheckState value)<br/>
at System.Windows.Forms.CheckBox.set_Checked(Boolean value)<br/>
at WindowsApplication1.Form1.InitializeComponent() in Cocuments and SettingsEdmy documentsvisual studio 2010ProjectsWindowsApplication1WindowsApplication1Form1.Designer.vb:line 71<br/>
at WindowsApplication1.Form1..ctor()<br/>
InnerException:
Ed. <hr class="sig ecb
View the full article
There are three (3) sections in this email. All sections is devided by =========================================
Below is the code that is provided.
private void clearButton_Click(object sender, EventArgs e)<br/>
{<br/>
// Clear the picture.<br/>
pictureBox1.Image = null;<br/>
}
private void backgroundButton_Click(object sender, EventArgs e)<br/>
{<br/>
// Show the color dialog box. If the user clicks OK, change the<br/>
// PictureBox controls background to the color the user chose.<br/>
if (colorDialog1.ShowDialog() == DialogResult.OK)<br/>
pictureBox1.BackColor = colorDialog1.Color;<br/>
}
private void closeButton_Click(object sender, EventArgs e)<br/>
{<br/>
// Close the form.<br/>
this.Close();<br/>
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)<br/>
{<br/>
// If the user selects the Stretch check box, <br/>
// change the PictureBoxs<br/>
// SizeMode property to "Stretch". If the user clears <br/>
// the check box, change it to "Normal".<br/>
if (checkBox1.Checked)<br/>
pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;<br/>
else<br/>
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;<br/>
}
Below is the Code when I get to Step 11 Run Your Program and Try Other Features<br/>
==================================================================================================<br/>
Public Class Form1
Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged<br/>
If (CheckBox1.Checked) Then<br/>
PicureBox1.SizeMode = PictureBoxSizeMode.StretchImage<br/>
Else<br/>
PictureBox1.SizeMode = PictureBoxSizeMode.Normal
End If<br/>
End Sub
Private Sub FlowLayoutPanel1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles FlowLayoutPanel1.Paint
End Sub
Private Sub PictureBox1_Click(sender As System.Object, e As System.EventArgs) Handles PictureBox1.Click
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TableLayoutPanel1_Paint(sender As System.Object, e As System.Windows.Forms.PaintEventArgs) Handles TableLayoutPanel1.Paint
End Sub
Private Sub showButton_Click(sender As System.Object, e As System.EventArgs) Handles showButton.Click
<br/>
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then<br/>
PictureBox1.Load(OpenFileDialog1.FileName)<br/>
End If
<br/>
End Sub
Private Sub closeButton_Click(sender As System.Object, e As System.EventArgs) Handles closeButton.Click<br/>
Close()
End Sub
Private Sub backgroundButton_Click(sender As System.Object, e As System.EventArgs) Handles backgroundButton.Click<br/>
If (ColorDialog1.ShowDialog() = DialogResult.OK) Then<br/>
PictureBox1.BackColor = ColorDialog1.Color
End If
<br/>
End Sub
Private Sub clearButton_Click(sender As System.Object, e As System.EventArgs) Handles clearButton.Click<br/>
PictureBox1.Image = DBNull
End Sub
Private Sub OpenFileDialog1_FileOk(sender As System.Object, e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
End Sub
Private Function DBNull() As Image<br/>
Throw New NotImplementedException<br/>
End Function
Private Function PicureBox1() As Object<br/>
Throw New NotImplementedException<br/>
End Function
End Class
When I click the START Debugging toolbar button I get the following errors.<br/>
I have no idea what to do at this point. I need help.
===================================================================================================<br/>
System.InvalidOperationException was unhandled<br/>
Message=An error occurred creating the form. See Exception.InnerException for details. The error is: The method or operation is not implemented.<br/>
Source=WindowsApplication1<br/>
StackTrace:<br/>
at WindowsApplication1.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190<br/>
at WindowsApplication1.My.MyProject.MyForms.get_Form1()<br/>
at WindowsApplication1.My.MyApplication.OnCreateMainForm() in Cocuments and SettingsEdmy documentsvisual studio 2010ProjectsWindowsApplication1WindowsApplication1My ProjectApplication.Designer.vb:line 35<br/>
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()<br/>
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()<br/>
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)<br/>
at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81<br/>
InnerException: System.NotImplementedException<br/>
Message=The method or operation is not implemented.<br/>
Source=WindowsApplication1<br/>
StackTrace:<br/>
at WindowsApplication1.Form1.PicureBox1() in Cocuments and SettingsEdmy documentsvisual studio 2010ProjectsWindowsApplication1WindowsApplication1Form1.vb:line 68<br/>
at WindowsApplication1.Form1.CheckBox1_CheckedChanged(Object sender, EventArgs e) in Cocuments and SettingsEdmy documentsvisual studio 2010ProjectsWindowsApplication1WindowsApplication1Form1.vb:line
5<br/>
at System.Windows.Forms.CheckBox.OnCheckedChanged(EventArgs e)<br/>
at System.Windows.Forms.CheckBox.set_CheckState(CheckState value)<br/>
at System.Windows.Forms.CheckBox.set_Checked(Boolean value)<br/>
at WindowsApplication1.Form1.InitializeComponent() in Cocuments and SettingsEdmy documentsvisual studio 2010ProjectsWindowsApplication1WindowsApplication1Form1.Designer.vb:line 71<br/>
at WindowsApplication1.Form1..ctor()<br/>
InnerException:
Ed. <hr class="sig ecb
View the full article