473,383 Members | 1,737 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,383 software developers and data experts.

Problems with enumeration and do/loop, while/ endwhile, for/next

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
2 1785
GlenC
3
please disregard, I posted in the wrong area
Oct 12 '08 #2
NeoPa
32,556 Expert Mod 16PB
Any interested parties can find the repost here (Loop and enumeration problems).
Oct 12 '08 #3

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

Similar topics

1
by: Jeremy Langworthy | last post by:
Hi I have a dynamicly generated form (well the elements are at least) that looks something like this: while( not end of returned records): <input name="plan_id" type="checkbox" id=""...
14
by: Henk | last post by:
Hi Guys, (see actual code below) I wrote a little program that is supposed to read a file (input.txt) into memory (using a stack) and then reverse the file and display it to output. It works,...
4
by: Marshal | last post by:
Sure... IEnumerable was inconvenient suggesting a separate class to service the enumeration, IEnumerator, and multiple operations: Current, MoveNext, Reset. (I'll warp the definition of "operation"...
1
by: Mark R. Dawson | last post by:
Hi, the Bitmap.LockBits method takes the ImageLockMode enumeration as a parameter. I may be missing something but if I supply a value of ImageLockMode.ReadOnly to the LockBits method I am still...
5
by: BeruthialsCat | last post by:
First go with trying to import xml to a database and whilst i have managed to do what i want i find that the xml files we have here at work are gonna cause me problems. I have a function that...
2
by: =?Utf-8?B?aGVyYmVydA==?= | last post by:
how do I code generic functions to return the next item in an enumeration a) sorted by name, b) sorted by value c) sorted by declaration in a round-robin style ? for example the enum is Enum...
6
by: JNeko | last post by:
Hello all, awesome site! I guess I am technically not a beginner in JAVA, but from my code you would not realize it! I don’t expect anyone to help me with this, but I figure I might as well as try...
2
by: recordlovelife | last post by:
So I am trying to display a title, date, and content of a wordpress blog. Word press provides nice drop in functions to get the job done with simple names like "the_title", and the "the_content" But...
1
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.