13 Replies - 915 Views - Last Post: 13 March 2012 - 05:14 PM Rate Topic: -----

#1 Swrzalinski  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 11-March 12

VB 10 Class Project Help

Posted 11 March 2012 - 05:59 PM

Hello, I'm doing a project for my beginners programming,logic, and design class. The project is a Sales Solution/Bonus Calculator. I really just want to know if I actually coded the array correctly. I've found the same project on here but I wasn't even really sure if what they had up was correct. I have a pretty solid idea of how to get through this I'm just feeling a bit overwhelmed. Any input or criticism is appreciated. If you notice any other errors please point them out. I'm not looking for the answer I'm just looking for the path to get there on my own merit. Here's what I have so far:

Public Class Form1

    Private Sub Report_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateReport.Click
        ' Calculates and displays bonus
        Dim decSales() As Integer = {"2400", "1500", "1600", "2970", "1000", "6300", "1300", "2700"}
        Dim IntCode As Integer

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click
        ' Closes Application
        Me.Close()
    End Sub

    Private Sub txtRateControl_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtRateControl.KeyPress
        If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
            AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar <> "." Then
            e.Handled = True
        End If
    End Sub


    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BonusDisplay.TextChanged
        'Display Bonus

    End Sub
End Class


Is This A Good Question/Topic? 0
  • +

Replies To: VB 10 Class Project Help

#2 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

Re: VB 10 Class Project Help

Posted 11 March 2012 - 06:07 PM

Okay your array looks good
So far you code does nothing...

Please tell me in pseudo code exactly what you want to happen...

It looks like you expect to update a textbox with the bonus amount. So it seems you are confused about how to approach this assignment.

Please list everything step by step that you want to happen.

This post has been edited by Toadill: 11 March 2012 - 06:10 PM

Was This Post Helpful? 0
  • +
  • -

#3 Swrzalinski  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 11-March 12

Re: VB 10 Class Project Help

Posted 11 March 2012 - 06:09 PM

SO far that's all I needed. I was just worried I didn't have the array setup properly. Thanks for the help.
Was This Post Helpful? 0
  • +
  • -

#4 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

Re: VB 10 Class Project Help

Posted 11 March 2012 - 06:13 PM

Do you understand what is happening when you create the array?

 Dim decSales() As Integer = {"2400", "1500", "1600", "2970", "1000", "6300", "1300", "2700"}



Tell me how many elements are in this array?
Tell me what is the highest index number in this array?

This is important I want to make sure you understand

This post has been edited by Toadill: 11 March 2012 - 06:13 PM

Was This Post Helpful? 0
  • +
  • -

#5 Swrzalinski  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 11-March 12

Re: VB 10 Class Project Help

Posted 11 March 2012 - 06:15 PM

I have 8 elements in the array and the highest index number would be 7 because my array starts with 0. Right?
Was This Post Helpful? 0
  • +
  • -

#6 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

Re: VB 10 Class Project Help

Posted 11 March 2012 - 06:18 PM

View PostSwrzalinski, on 11 March 2012 - 08:15 PM, said:

I have 8 elements in the array and the highest index number would be 7 because my array starts with 0. Right?


You got it great job :rockon:

Okay tell me how would you assign a new value to the 6th index spot in your array?
Was This Post Helpful? 1
  • +
  • -

#7 Swrzalinski  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 11-March 12

Re: VB 10 Class Project Help

Posted 11 March 2012 - 06:25 PM

I can't even answer that. I mean I know I could just remove the sixth item in the code and replace it with another number, but that clearly isn't what you're asking. I hate having a book that is explaining using arrays and it's all examples. I keep flipping through my previous projects which are pretty much laid out step by step and it is becoming frustrating. I can kind of see where I am supposed to be headed I know I need to lay out an equation at some point in here because I need to multiply all of the items in the array by whatever number is input and then have all the results displayed in my text box and then have those answers totalled and also displayed in the text box.
Was This Post Helpful? 0
  • +
  • -

#8 shadachi  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 141
  • Joined: 25-January 08

Re: VB 10 Class Project Help

Posted 11 March 2012 - 06:40 PM

Why not just replace the values ? =D

You know you could overwrite manually to your arrays using the indexes.

For example
You initialize it with the following
decSales(5) = 1234


To change it manually , you could overwrite it with a new value
decSales(5) = 0000
Was This Post Helpful? 1
  • +
  • -

#9 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 96
  • View blog
  • Posts: 899
  • Joined: 15-October 10

Re: VB 10 Class Project Help

Posted 11 March 2012 - 06:54 PM

Trust me there is no one on this site that doesn't get frustrated. welcome to the world of program keep at it it will get easier the more you learn and every one at dic is glad to help. good luck
Was This Post Helpful? 1
  • +
  • -

#10 Toadill  Icon User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 401
  • Joined: 08-January 12

Re: VB 10 Class Project Help

Posted 12 March 2012 - 06:41 AM

View Postshadachi, on 11 March 2012 - 08:40 PM, said:

Why not just replace the values ? =D

You know you could overwrite manually to your arrays using the indexes.

For example
You initialize it with the following
decSales(5) = 1234


To change it manually , you could overwrite it with a new value
decSales(5) = 0000


Yes this is correct, it is not that hard.
If we wanted the fifth spot we would use

'You can assign any value you like as long as it matches the data type of the array.
decSales(4) = 1981


This post has been edited by Toadill: 12 March 2012 - 06:42 AM

Was This Post Helpful? 1
  • +
  • -

#11 Swrzalinski  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 11-March 12

Re: VB 10 Class Project Help

Posted 12 March 2012 - 11:42 AM

Here's the progress that I've made and yes I have errors. Again my goal here is to multiply the objects in my array by the bonusRate and then have that displayed as the salesBonus which I'm then trying to add together to give me my bonusTotal. Am I at least heading in the right direction?
Public Class Form1

    Private Sub Report_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateReport.Click
        ' Calculates and displays bonus
        Dim intSales() As Integer = {"2400", "1500", "1600", "2970", "1000", "6300", "1300", "2700"}
        Dim bonusRate As Decimal
        Dim salesBonus As Decimal
        Dim bonusTotal As Decimal

        Decimal.TryParse(txtRate.Text, bonusRate)
        Integer.TryParse(txtReport.Text, bonusTotal)

        bonusTotal = 0
        bonusTotal = bonusTotal + salesBonus

        txtReport = "Bonus Total" & ControlChars.NewLine

Was This Post Helpful? 0
  • +
  • -

#12 shadachi  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 141
  • Joined: 25-January 08

Re: VB 10 Class Project Help

Posted 13 March 2012 - 12:48 AM

you may use a loop to Loop through your array and multiply it with your bonusRate .

It really depends on how you want to display it . Not sure whether it works or not. Just blurt it out on the spot



Dim BonusRate as Decimal = 0
Dim bonusTotal As Decimal = 0

If Decimal.TryParse(txtRate.Text , BonusRate ) = true then

For each sales as integer in IntSales

bonusTotal += ( sales * BonusRate  ) 

Next

end if


txtReport.text = bonusTotal.ToString()



Was This Post Helpful? 1
  • +
  • -

#13 DimitriV  Icon User is offline

  • They don't think it be like it is, but it do
  • member icon

Reputation: 583
  • View blog
  • Posts: 2,738
  • Joined: 24-July 11

Re: VB 10 Class Project Help

Posted 13 March 2012 - 01:50 AM

View Postm_wylie85, on 12 March 2012 - 11:54 AM, said:

Trust me there is no one on this site that doesn't get frustrated. welcome to the world of program keep at it it will get easier the more you learn and every one at dic is glad to help. good luck

Nobody's prefect. We all make mistakes but it's how we learn. We all want to help, because we were all noobs at one stage and we want to help the rest of us along.
It feels good to help.
Was This Post Helpful? 1
  • +
  • -

#14 shadachi  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 141
  • Joined: 25-January 08

Re: VB 10 Class Project Help

Posted 13 March 2012 - 05:14 PM

true story DimitriV .. True story..
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1