Help Cleanup My Coding
Help Cleanup My Coding
Help Cleanup My Coding
Help Cleanup My Coding
Help Cleanup My Coding
Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding
Help Cleanup My Coding Help Cleanup My Coding
Help Cleanup My Coding
Go Back  Xtreme Visual Basic Talk > > > Help Cleanup My Coding


Reply
 
Thread Tools Display Modes
  #1  
Old 07-14-2009, 02:26 PM
macdonjo macdonjo is offline
Newcomer
 
Join Date: Jul 2009
Posts: 1
Unhappy Help Cleanup My Coding


Anyone wanna give me a hand with my picture viewer? THANKS!

Code:
Public Class Form1

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        Show.PictureBox1.Image = Path
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.ShowDialog()
        If PictureBox1.Image = 1600 x 1200 Then
            Exit
        Else
            SizeMode = Strech

        and if PictureBox1.Image = Jpeg.Format then
            continue
            else MsgBox ("Must be .Jpeg Formate.")
        End If
    End Sub

    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        PictureBox1.Image = New Bitmap(OpenFileDialog1.FileName)
    End Sub
End Class

Last edited by OnErr0r; 07-14-2009 at 02:55 PM. Reason: Removed email info
Reply With Quote
  #2  
Old 07-14-2009, 02:57 PM
AtmaWeapon's Avatar
AtmaWeaponHelp Cleanup My Coding AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

We don't communicate privately via email on this forum; it defeats the purpose of having a public forum. Nonetheless, here's my comments:
  • PictureBox.Image is a property of type System.Drawing.Image. Your TextChanged handler tries to set it to some global variable that's not declared anywhere; my guess is it's a string. This is a compilation error and a logic error.
  • You don't check the return value of ShowDialog(); what if the user clicked "Cancel"?
  • Again, Image is an Image; PictureBox1.Image = 1600 x 1200 fails because to the compiler it looks like you're trying to set the image to the number 1600 with some stray text around. If you're trying to check the size of the image, use the image's Size property and the System.Drawing.Size class.
  • Exit shouldn't be called to exit an application. Application.Exit() can be used in the worst case, but it's preferred to just close your form.
  • "Strech" is misspelled and not a valid SizeMode value; you probably meant SizeMode.Stretch. Since you don't ever set it to any other value, this is probably frivolous.
  • and if should be If.
  • Image is an Image. "Jpeg.Format" is some random characters you typed. You can get the type of an Image using the RawFormat property, which returns a System.Drawing.Imaging.ImageFormat that represents the format (this may or may not be correct, but it's closer):
    Code:
    If PictureBox1.Image.RawFormat = ImageFormat.Jpeg Then
  • The code won't do what you think. The FileOk event is raised when the user clicks "Open" in the open file dialog that is opened as part of Button1_Click(), but since the computer is busy with Button1_Click() the FileOk handler won't run until the button click handler is finished. It'd be better to check the return value of ShowDialog() as discussed before:
    Code:
    Dim result As DialogResult = OpenFileDialog1.ShowResult()
    
    If result <> DialogResult.OK Then
        ' user clicked "OK"
        Return
    End If
    
    ' From here on, you know the user clicked the "OK" analog
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Help Cleanup My Coding
Help Cleanup My Coding
Help Cleanup My Coding Help Cleanup My Coding
Help Cleanup My Coding
Help Cleanup My Coding
Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding Help Cleanup My Coding
Help Cleanup My Coding
Help Cleanup My Coding
 
Help Cleanup My Coding
Help Cleanup My Coding
 
-->