Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 244,306 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 784 people online right now. Registration is fast and FREE... Join Now!




VB Project

 
Reply to this topicStart new topic

VB Project, statement is not valid in a namespace

gdcmf
5 Oct, 2008 - 08:29 PM
Post #1

New D.I.C Head
*

Joined: 5 Oct, 2008
Posts: 2

Ok I solved that problem, here is my new code.
CODE
Option Strict On

Public Class Form1

    'Declare module-level constants.
    Const BONUS_PERCENT_Decimal As Decimal = 0.02D
    Const FOUR_WEEK_Integer As Integer = 160

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintForm1.Click
        'Calculate the bonus earned by each employee
        Dim SalesDecimal, HoursDecimal, BonusDecimal As Decimal

        Try
            'Convert store sales if valid input
            SalesDecimal = Decimal.Parse(SalesTextBox.Text)
            Try
                'Convert hours if valid input
                HoursDecimal = Decimal.Parse(HoursTextBox.Text)

                'Calculate and display the bonus
                BonusDecimal = (HoursDecimal / FOUR_WEEK_Integer) * (SalesDecimal * BONUS_PERCENT_Decimal)
                BonusTextBox.Text = BonusDecimal.ToString("C")

            Catch HoursException As FormatException
                'Handle the number of hours
                MessageBox.Show("Hours must be numeric data.", "Invalid Input", _
                    MessageBoxButtons.OK, MessageBoxIcon.Error)
                With HoursTextBox
                    .Focus()
                    .SelectAll()
                End With
            End Try
        Catch SalesException As FormatException
            'Handle the amount of sales
            MessageBox.Show("Sales must be numeric data.", "Invalid Input", _
                MessageBoxButtons.OK, MessageBoxIcon.Error)
            With SalesTextBox
                .Focus()
                .SelectAll()
            End With
        Catch AnException As Exception
            MessageBox.Show("Error: " & AnException.Message)
        End Try
    End Sub



    Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearButton.Click
        'Clear the form

        HoursTextBox.Clear()
        BonusTextBox.Clear()
        With NameTextBox
            .Clear()
            .focus()
        End With
    End Sub

    Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        'End the program

        Me.Close()
    End Sub

    Private Sub PrintButton_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PrintButton.Click
        'Print the form

        PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
        PrintForm1.Print()
    End Sub

End Class



and here are my errors:
Error 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. H:\Visual Studio 2008\Projects\VB Mail Order 1\jps27\jps27\Form1.vb 48 103 jps27
Error 2 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. H:\Visual Studio 2008\Projects\VB Mail Order 1\jps27\jps27\Form1.vb 59 102 jps27
Error 3 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. H:\Visual Studio 2008\Projects\VB Mail Order 1\jps27\jps27\Form1.vb 65 103 jps27
Error 4 'PrintAction' is not a member of 'System.Windows.Forms.Button'. H:\Visual Studio 2008\Projects\VB Mail Order 1\jps27\jps27\Form1.vb 68 9 jps27
Error 5 'Print' is not a member of 'System.Windows.Forms.Button'. H:\Visual Studio 2008\Projects\VB Mail Order 1\jps27\jps27\Form1.vb 69 9 jps27

Thanks for your help

This post has been edited by gdcmf: 5 Oct, 2008 - 09:00 PM

User is offlineProfile CardPM
+Quote Post


thava
RE: VB Project
5 Oct, 2008 - 08:46 PM
Post #2

D.I.C Addict
Group Icon

Joined: 17 Apr, 2007
Posts: 670



Thanked: 35 times
Dream Kudos: 75
My Contributions
creaete new form and copy this coding in to the form code window
User is offlineProfile CardPM
+Quote Post

gdcmf
RE: VB Project
5 Oct, 2008 - 09:22 PM
Post #3

New D.I.C Head
*

Joined: 5 Oct, 2008
Posts: 2

I figured out the errors. Sorry to waste anyone's time. Thanks though.
User is offlineProfile CardPM
+Quote Post

akhileshbc
RE: VB Project
6 Oct, 2008 - 12:15 AM
Post #4

D.I.C Head
Group Icon

Joined: 26 Sep, 2008
Posts: 177



Thanked: 6 times
Dream Kudos: 50
My Contributions
This should b in the .net section smile.gif
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: VB Project
6 Oct, 2008 - 05:26 AM
Post #5

loves.Coding(this);
Group Icon

Joined: 26 Jul, 2007
Posts: 12,288



Thanked: 372 times
Dream Kudos: 10775
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Moved to VB.NET smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 06:36PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month