Jump to content

Need more help with school code

cab11150904

I am looking for the best way to apply a set discount to the code that I am applying.  I will just copy the question so I can get some ideas on the best way to do it or the way you guys would use.  I am programming in VB.Net.

 

LSaDaVd.png

 

 

 

twjLa8S.png

Link to comment
Share on other sites

Link to post
Share on other sites

A switch statement? Using math? I don't understand what your specific question is.

Link to comment
Share on other sites

Link to post
Share on other sites

input quatity

item price * discount price 

any other questions?

|Casual Rig| CPU: i5-6600k |MoBo: ROG Gene  |GPU: Asus 670 Direct CU2 |RAM: RipJaws 2400MHz 2x8GB DDR4 |Heatsink: H100i |Boot Drive: Samsung Evo SSD 240GB|Chassis:BitFenix Prodigy |Peripherals| Keyboard:DasKeyboard, Cherry MX Blue Switches,|Mouse: Corsair M40

|Server Specs| CPU: i7-3770k [OC'd @ 4.1GHz] |MoBo: Sabertooth Z77 |RAM: Corsair Vengeance 1600MHz 2x8GB |Boot Drive: Samsung 840 SSD 128GB|Storage Drive: 4 WD 3TB Red Drives Raid 5 |Chassis:Corsair 600t 

Link to comment
Share on other sites

Link to post
Share on other sites

input quatity

item price * discount price 

any other questions?

Yeah a few more.  Where would I enter the code and how exactly would you state that in code?  I think I grasp what you mean but I'm not sure.  I'm going to switch over and try it and I'll check back to see if you've added more.

 

Edit: Also how would I go about breaking it down to Package A, B, and C in one label like it shows on the page?

Link to comment
Share on other sites

Link to post
Share on other sites

I would create a variable called A,B,C which would all = their price right. Then id have an if statement after the user inputs their ammount to buy which looks up to a set of variables with the discount price. As in where to put it , not a clue its been awhile.

|Casual Rig| CPU: i5-6600k |MoBo: ROG Gene  |GPU: Asus 670 Direct CU2 |RAM: RipJaws 2400MHz 2x8GB DDR4 |Heatsink: H100i |Boot Drive: Samsung Evo SSD 240GB|Chassis:BitFenix Prodigy |Peripherals| Keyboard:DasKeyboard, Cherry MX Blue Switches,|Mouse: Corsair M40

|Server Specs| CPU: i7-3770k [OC'd @ 4.1GHz] |MoBo: Sabertooth Z77 |RAM: Corsair Vengeance 1600MHz 2x8GB |Boot Drive: Samsung 840 SSD 128GB|Storage Drive: 4 WD 3TB Red Drives Raid 5 |Chassis:Corsair 600t 

Link to comment
Share on other sites

Link to post
Share on other sites

I am using VB.net.  My question is how do I get my program to display the results of three different equations and the grand total in the same label? Also how can I make the lines say Package A, Package B, and Package along with Grand total as static text that the results will display after? Example below.

 

gXBkrOH.png

Link to comment
Share on other sites

Link to post
Share on other sites

Didn't you already ask this question and get an answer?

 

1. It's not a Label, it's a TextBox with the Multiline and ReadOnly properties set.

2. Concatenate strings

3. Environment.Newline will be useful

Link to comment
Share on other sites

Link to post
Share on other sites

Didn't you already ask this question and get an answer?

 

1. It's not a label, it's a TextBox with the multi-line property set.

2. Concatenate strings

3. Environment.Newline will be useful

No I asked the question that got me to this point.  I have huge problems with math so the formulas confuse me sometimes.  As for the label and textbox thing, the book says that it is a Label control so I will be graded on that part.  I used  

 

lblResults.Text = "Package A: " & vbNewLine & "Package B:" & vbNewLine & "Package C" & vbNewLine & "" & vbNewLine & "Grand Total:"

 

to get the words there so now I just need to know how to add the totals to those specific lines so it will keep the static text but change the numbers to match the math. Also thanks for the help so far.

Link to comment
Share on other sites

Link to post
Share on other sites

Yeah a few more.  Where would I enter the code and how exactly would you state that in code?  I think I grasp what you mean but I'm not sure.  I'm going to switch over and try it and I'll check back to see if you've added more.

 

Edit: Also how would I go about breaking it down to Package A, B, and C in one label like it shows on the page?

 

I would create a variable called A,B,C which would all = their price right. Then id have an if statement after the user inputs their ammount to buy which looks up to a set of variables with the discount price. As in where to put it , not a clue its been awhile.

 

Put it all after you defined the variables and did all of the changes (besides for this one of course) but before you print it

Link to comment
Share on other sites

Link to post
Share on other sites

you should be able to do something like this lblResults.Text = "Package A:" & intPackA & vbNewLine &.... and so forth. intPackA being your value for package A.

My Gaming Rig (Build November 2014):

CPU: i7-4790K | CPU Cooler: H110 | Motherboard: MSI Z97s SLI Plus | RAM: Vengeance DDR3 1886 MHz 2 x 4GB |
GPU: GTX 970 G1 Gaming | SSD: 2 x 840 EVO 250GB and 2 x 850 EVO 250GB in RAID0 | PSU: HX750 | Case: Fractal Design XL R2 |

Link to comment
Share on other sites

Link to post
Share on other sites

No I asked the question that got me to this point.  I have huge problems with math so the formulas confuse me sometimes.  As for the label and textbox thing, the book says that it is a Label control so I will be graded on that part.

 

My mistake. Looked like a TextBox to me at first glance but you can have a multi-line Label with a border which looks similar and is where I got mixed up.

Link to comment
Share on other sites

Link to post
Share on other sites

you should be able to do something like this lblResults.Text = "Package A:" & intPackA & vbNewLine &.... and so forth. intPackA being your value for package A.

I tried something like that but it fudged somewhere. I'll try again.

Link to comment
Share on other sites

Link to post
Share on other sites

I did this on my phone so it's probably not right but something like this should work (if I remember VB auto converts int to string, right?):

Dim ValueA As int;

Dim ValueB As int;

Dim ValueC As int;

 

Output.text= "Package A: " + (ValueA * TextBox1.text) + Environment.Newline + "Package B: " + (ValueB * TextBox2.text) + "Package C: " + (ValueA * TextBox3.text);

Link to comment
Share on other sites

Link to post
Share on other sites

you should be able to do something like this lblResults.Text = "Package A:" & intPackA & vbNewLine &.... and so forth. intPackA being your value for package A.

I figured it out.  I forgot the & between my static text and my variable.

Link to comment
Share on other sites

Link to post
Share on other sites

I did this on my phone so it's probably not right but something like this should work (if I remember VB auto converts int to string, right?):

Dim ValueA As int;

Dim ValueB As int;

Dim ValueC As int;

 

Output.text= "Package A: " + (ValueA * TextBox1.text) + Environment.Newline + "Package B: " + (ValueB * TextBox2.text) + "Package C: " + (ValueA * TextBox3.text);

I used xboxonthego3's code and it worked but thanks for your help.

Link to comment
Share on other sites

Link to post
Share on other sites

I used xboxonthego3's code and it worked but thanks for your help.

 You're welcome! Ha i'm in a programming class right now and was just browsing linustechtips. And saw your post. I never thought about using this forum as a resource. So thanks for showing me! :D

My Gaming Rig (Build November 2014):

CPU: i7-4790K | CPU Cooler: H110 | Motherboard: MSI Z97s SLI Plus | RAM: Vengeance DDR3 1886 MHz 2 x 4GB |
GPU: GTX 970 G1 Gaming | SSD: 2 x 840 EVO 250GB and 2 x 850 EVO 250GB in RAID0 | PSU: HX750 | Case: Fractal Design XL R2 |

Link to comment
Share on other sites

Link to post
Share on other sites

 You're welcome! Ha i'm in a programming class right now and was just browsing linustechtips. And saw your post. I never thought about using this forum as a resource. So thanks for showing me! :D

Hey no problem.  I just figured anything was better than Reddit.  The assignment is done and handed in and I expect a 100 since it all works as it should.  

Link to comment
Share on other sites

Link to post
Share on other sites

Hey no problem.  I just figured anything was better than Reddit.  The assignment is done and handed in and I expect a 100 since it all works as it should.  

There are plenty of reasons why you may not get 100 even though the answer is right

  • Messy code
  • Poor documentation
  • Bugs
  • Missing requirements
  • etc

But hopefully you will get it :)

Link to comment
Share on other sites

Link to post
Share on other sites

There are plenty of reasons why you may not get 100 even though the answer is right

  • Messy code
  • Poor documentation
  • Bugs
  • Missing requirements
  • etc

But hopefully you will get it :)

No documentation needed, code works so that's what he'll care about and the program looks to spec and produces the right kind of numbers.  It's very basic level programming so the assignment should be 100%.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×