473,387 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Loop and enumeration problems

3
Hello everyone,

I'm brand new to this forum and have not yet trolled through all the posts so bear with me please.

I am a beginner at VB.Net programming (using VB express 2008) and (of course) am having some trouble with a particular assignment for my programming class.

I am trying to enumerate an array as simply as possible but I lack some experience. I am not allowed to use anything predefined to create this list. but here goes.

This is the code I have so far:

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalc.Click
  2.         Dim rows As Integer
  3.         Dim Sum As Integer
  4.         Dim Spacing As Integer
  5.         Dim Pins As Integer
  6.         Dim Cost As Integer
  7.         Dim Revenue As Integer
  8.         Dim Profit As Integer
  9.         Dim Average As Integer
  10.         Dim counter As Integer
  11.         Pins = 'Here's where the breakdown occurs...How do I make the program (while enumerating columns) prompt me for Pins values?
  12.         counter = 0
  13.         Sum = 0
  14.         rows = numIterations.Value And rows <> 0
  15.         If rows >= 1 Then
  16.             Spacing = Int(1000 / rows)
  17.         End If
  18.         Do Until (Int(rows) >= rows)
  19.             counter = counter + 1
  20.             While (counter <= rows)
  21.  
  22.                 For Spacing = 1 To 1000 Step 2
  23.                 Next
  24.                 Cost = 100000 + 12 * Pins
  25.                 Revenue = Pins * (1000 - Pins)
  26.                 Profit = Revenue - Cost
  27.                 Sum = Sum + Profit
  28.  
  29.  
  30.             End While
  31.         Loop
  32.         txtTable.AppendText("Number                         " & "Cost                         " & "Revenue                         " & "Profit                         ")
  33.         txtTable.AppendText(ControlChars.CrLf)
  34.         If rows >= 1 Then
  35.             Average = Sum / rows
  36.         End If
  37.         txtTable.AppendText(ControlChars.CrLf)
  38.         txtTable.AppendText(ControlChars.CrLf)
  39.         txtTable.AppendText("Average Profit: " & FormatCurrency(Average).ToString())
  40.  
  41.     End Sub
It's supposed to look like 4 columns with the info for each row lined up under its corresponding column. The form setup is a label that describes what belongs in the numupdownbox with a button next to it to activate this section of code above. I am almost sure that I have something out of order but I don't know what. In essence however, the problem I have is this: how does telling the code above how many rows there are (by way of numIterations.Value) equate to a prompt for the value "pins"? There are no syntax errors or exception errors that VB studio can find - it does exactly what I tell it to do during debugging (I'm just not telling it what want correctly, apparently).
I realize this topic is probably beaten to death but at this point anything I can get by way of advice or a nod in the right direction is helpful...as for the grade on this assignment...I don't even care about it - I just want to know so I can get it right.


Thanks in advance
Oct 12 '08 #1
1 1407
NeoPa
32,556 Expert Mod 16PB
Sorry Glen, I know you tried, but this wants to be in the .NET forum so I'll just move it over for you.

Good luck, and welcome to Bytes!

PS. For interested experts - Although this is a homework/assignment question, it is acceptable to help as the OP has made clear what they've tried and that they are interested in learning from the process rather than attempting simply to get better marks per se.
Oct 12 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Gordon Williams | last post by:
Hi, I have been using this code for a number of weeks without problems. Now I am getting an exception after the program has run a short while. It has already passed through this function...
1
by: Justin Wright | last post by:
I know that I can set up an enumeration as follows ( just typed in quick so may have syntax errors ): <xsd:simpleType name="colors"> <xsd:restriction base="xsd:string"> <xsd:enumeration...
25
by: David C | last post by:
I posted this question, and from the replies, I get the impression that I worded my posting very poorly, so let me try this again. While debugging and stepping through this foreach loop ...
1
by: Tim | last post by:
Hi, I'm very new to .NET and am programming in C#. I have a web application where i have two list boxes. Its kind of like a shopping card where you can add items from one 'locations' list box to...
1
by: G. Dean Blake | last post by:
When I do this..... myDA.SelectCommand.Parameters("@SCID").Value = scid Dim dt As New DataTable myDA.Fill(dt) If dt.Rows.Count > 0 Then Dim myRow As DataRow = dt.Rows(0) For Each myRow In...
27
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to...
9
by: Fred Zwarts | last post by:
What is the recommended way to loop over all enum values of a certain enum type? Consider the following definition: typdef enum {A=2, B, C=5, D} E; then for (E x = A; x <= D; ++x) { ... }
4
by: shapper | last post by:
Hello, I have an enumeration as follows: public enum RoleType { Administrator, Collaborator, ... }
2
by: GlenC | last post by:
Hello everyone, I'm brand new to this forum and have not yet trolled through all the posts so bear with me please. I am a beginner at VB.Net programming (using VB express 2008) and (of course)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.