Jump to content
Xtreme .Net Talk

tomwjr

Members
  • Posts

    5
  • Joined

  • Last visited

tomwjr's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Here is what I have gotten so far... Public Sub btnAdd_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnAdd.Click Dim iScoreCount As Integer Dim dScore() As Decimal = {FormatNumber(txtScore.Text)} Dim dScoreTotal As Decimal Dim dScoreText As Decimal For iScoreCount = 0 To dScore.GetUpperBound(0) ReDim Preserve dScore(iScoreCount) iScoreCount += 1 Next iScoreCount For iScoreCount = 0 To dScore.GetUpperBound(0) dScoreTotal += dScore(iScoreCount) Next iScoreCount lblScoreCount.Text = iScoreCount lblScoreTotal.Text = dScoreTotal End Sub So...now I get one variable into the array, but I cannot seem to figure out how to add another variable. When I enter a new number into the txtbox, it simply over-writes the old number and lblScoreTotal.Text continues to read 1 . Can anyone tell me how to get this dumb program to continue adding variables to the array until I tell it to stop?
  2. Yeah, I'm not sure what the point of the exercise is, but I am really strugleing with it.
  3. The assignment states to us a one-dimensional array to store the scores. The array needs to be declared without an initial size and we have to use the redim statement to resize each time a score is added. Due to this we are limited in the options we have.
  4. I am trying to create a one-dimensional array without size from text entered into a textbox. I then use the redim statement to resize the array. I have tried two different approaches without success. The first was setting the textbox up as the array: Dim txtScore() As TextBox Dim iScoreCount As Integer For ReDim Preserve txtScore(iScoreCount) iScoreCount += 1 Next The second was setting up the array and trying to get data from the textbox to the array: Dim dScore As Decimal Dim iScoreCount As Integer For dScore(iScoreCount) = txtScore.Text 'this is a syntax error iScoreCount += 1 Next I was able to get the first entry into the textbox into the array, but could not get anything further into it. I used the following to check: lblScoreCount.Text = iScoreCount I would get a "1" in the label, but when I tried to enter another number into the textbox, nothing would happen. Any ideas on how to get the loop to work, or am I making this much harder than it has to be?
×
×
  • Create New...