Wrox Programmer Forums
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 24th, 2007, 08:30 PM
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default i need help quick

ok well lest start with what i'm trying to do.. I need to make a program to take inputs ( item name and amount in $ of how much was sold each day of the week) that all needs to be in one line
it needs to be able to hold 5 different items. and it is 7 rows and 5 columns and
the columns are (item name) (one for monday - friday) (total)
at the very end i also need a gross sales of the entire week
here is a list of my textbox's i am using for inputs

itemtext
mondaytextbox
tuesdaytextbox
wednesdaytextbox
thursdaytextbox
fridaytextbox
submitbutton
itemsalesbox
grosssaleslabel

i think all the items are all self explanitory well heres my code so far any help at all would be very amazing

================================================== ================
Public Class SalesReportForm

    Dim itemCount As Integer = 0
    Dim itemlistbox(,) As String = New String(0 To 9, 0 To 6) {}
------------------------------------------------------------------
    Private Sub submitButton_Click(ByVal sender As System.Object, _
       ByVal e As System.EventArgs) Handles submitButton.Click

        DisplaySales()

        ' clear TextBox input

        itemText.Clear()
        mondayTextBox.Clear()
        tuesdayTextBox.Clear()
        wednesdayTextBox.Clear()
        thursdayTextBox.Clear()
        fridayTextBox.Clear()


        'some of these could be wrong also i dunno

        Dim counter As Integer = 0
        Dim monday As Decimal
        Dim tuesday As Decimal
        Dim wednesday As Decimal
        Dim thursday As Decimal
        Dim friday As Decimal
        Dim total As Decimal
        Dim itemtotal As Decimal


        'not sure if these are working or even doing nething sorry i don't know much about this program

        ' i know it needs a lot of working on
        monday = CDec(Val(mondayTextBox.Text))
        tuesday = CDec(Val(tuesdayTextBox.Text))
        wednesday = CDec(Val(wednesdayTextBox.Text))
        thursday = CDec(Val(thursdayTextBox.Text))
        friday = CDec(Val(fridayTextBox.Text))

        ' if i don't need anything on here feel free to take it out the cleaner the better

        itemlistbox(itemCount, 0) = itemText.Text
        itemlistbox(itemCount, 1) = mondayTextBox.Text
        itemlistbox(itemCount, 2) = tuesdayTextBox.Text
        itemlistbox(itemCount, 3) = wednesdayTextBox.Text
        itemlistbox(itemCount, 4) = thursdayTextBox.Text
        itemlistbox(itemCount, 5) = fridayTextBox.Text
        itemlistbox(itemCount, 6) = mondayTextBox.Text + tuesdayTextBox.Text + wednesdayTextBox.Text + thursdayTextBox.Text + fridayTextBox.Text
        total = monday + tuesday + wednesday + thursday + friday

        itemCount += 1

        ' check if 10 items have been entered
        If itemCount = 10 Then
            submitButton.Enabled = False
        End If
    End Sub ' submitButton_Click
----------------------------------------------------------
    Sub DisplaySales()

        ' clear the ListBox
        itemsalesbox.Items.Clear()

        ' create a header for the ListBox
        itemsalesbox.Items.Add("Name" & ControlChars.Tab & _
           ControlChars.Tab & "Mon." & ControlChars.Tab & "Tue." & _
           ControlChars.Tab & "Wed." & ControlChars.Tab & "Thu." & _
           ControlChars.Tab & "Fri." & ControlChars.Tab & "Total")

        Dim output As String
    End Sub ' DisplaySales
End Class ' SalesReportForm
================================================== ==============

 
Old October 24th, 2007, 09:38 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Help with WHAT? You have explained what you WANT to do but not what your code IS or IS NOT doing.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old October 24th, 2007, 09:41 PM
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well i want my code to do that... my code actually doesn't do anything right now i type in my inputs and click then nothing happens.

 
Old October 25th, 2007, 07:44 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Have you tried stepping through your code? Does your Click event handler execute?

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old October 25th, 2007, 08:55 AM
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well when i click on the button the text boxes clear and it puts the headers in the list box but nothing else

 
Old October 25th, 2007, 09:01 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

How do you expect this code:
        monday = CDec(Val(mondayTextBox.Text))
        tuesday = CDec(Val(tuesdayTextBox.Text))
        wednesday = CDec(Val(wednesdayTextBox.Text))
        thursday = CDec(Val(thursdayTextBox.Text))
        friday = CDec(Val(fridayTextBox.Text))
to return anything other then 0 when you call this code directly before it:
        itemText.Clear()
        mondayTextBox.Clear()
        tuesdayTextBox.Clear()
        wednesdayTextBox.Clear()
        thursdayTextBox.Clear()
        fridayTextBox.Clear()

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old October 25th, 2007, 09:05 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

And, in fact, how does this not throw an InputString exeception? Trying to convert an empty string to a Decimal will most certainly throw that error.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old October 25th, 2007, 09:49 AM
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i know sorry for not using posting rules but i have till tonight to finish this here's my updated code it still doesn't input the sales values but it does input the item name


================================================== =
Public Class SalesReportForm

   Dim itemCount As Integer = 0
    Dim itemNames(0 To 9) As String
    Dim itemsales(,) As String = New String(0 To 9, 0 To 6) {}
    Dim count As Integer = 1
    Dim monday As String
    Dim names As String
    Dim itemtotal As Double
    Dim total As Integer


   ' handles Submit Button's Click event
   Private Sub submitButton_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles submitButton.Click

        If count = 1 Then
            DisplaySales()
        End If



        names = itemTextBox.Text
        monday = mondayTextBox.Text


        outputListBox.Items.Add(names)
        itemsales(itemCount, 1) = (monday)
        itemsales(itemCount, 2) = tuesdayTextBox.Text
        itemsales(itemCount, 3) = wednesdayTextBox.Text
        itemsales(itemCount, 4) = thursdayTextBox.Text
        itemsales(itemCount, 5) = fridayTextBox.Text

        itemCount += 1

        tuesdayTextBox.Clear()
        mondayTextBox.Clear()
        wednesdayTextBox.Clear()
        thursdayTextBox.Clear()
        fridayTextBox.Clear()
        itemTextBox.Clear()
        Do While count < itemCount
            itemtotal += Convert.ToDouble(itemsales(itemCount, 1))
            count += 1
        Loop




        If count > 10 Then
            submitButton.Enabled = False
        End If


        ' check if 10 items have been entered
        If itemCount = 10 Then
            submitButton.Enabled = False
        End If
    End Sub ' submitButton_Click

   Sub DisplaySales()

      ' clear the ListBox


        If count = 1 Then
            ' create a header for the ListBox
            outputListBox.Items.Add("Name" & ControlChars.Tab & _
               ControlChars.Tab & "Mon." & ControlChars.Tab & "Tues." & _
               ControlChars.Tab & "Wed." & ControlChars.Tab & "Thur." & _
               ControlChars.Tab & "Fri." & ControlChars.Tab & "Total")
        End If
        Dim output As String
    End Sub ' DisplaySales
End Class ' SalesReportForm
================================================== =================

 
Old October 25th, 2007, 09:53 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

You never add the data in your Array to the list box. The only time you ever write data to the list box is here:
   Sub DisplaySales()

      ' clear the ListBox


        If count = 1 Then
            ' create a header for the ListBox
            outputListBox.Items.Add("Name" & ControlChars.Tab & _
               ControlChars.Tab & "Mon." & ControlChars.Tab & "Tues." & _
               ControlChars.Tab & "Wed." & ControlChars.Tab & "Thur." & _
               ControlChars.Tab & "Fri." & ControlChars.Tab & "Total")
        End If
        Dim output As String
    End Sub ' DisplaySales

And this statement:
Dim output as String is unnecssary. You don't do anything with it, its declared at the end of your method, and is out of scope for all the other methods in your class.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old October 25th, 2007, 07:56 PM
Registered User
 
Join Date: Oct 2007
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well how would i add the monday tuesday wednesday thursday and friday values to the array??






Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a quick job done iced1992 Beginning PHP 0 January 9th, 2008 11:11 AM
another quick question andyhague XSLT 2 March 21st, 2006 12:13 PM
Need Quick Help yikomaka Visual C++ 1 September 1st, 2005 05:33 PM
Just a quick one!!!(again) satts Access 11 February 22nd, 2005 06:36 PM
Need quick help please! lryckman Access VBA 2 January 12th, 2004 12:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.