| | |
Math concerning Arrays and Ubound.. coding now!
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 5
Reputation:
Solved Threads: 0
Alright.. i figured out mostly everything but my math is still screwing me up. I need to accumulate running totals for number of checks and number of deposits ;and total value of checks and total value of deposits. Im supposed to do this by looping through my arrays and this is what I have so far:
Private Sub LoadArrayElements()
strTransDate(UBound(strTransDate)) = dtpTransDate.ToString
objCheckNum(UBound(objCheckNum)) = txtCheck.Text
strPayee(UBound(strPayee)) = txtPayee.Text
strPurpose(UBound(strPurpose)) = txtPurpose.Text
End Sub
Call LoadArrayElements()
'*Redim arrays to add new element
ReDim Preserve strTransDate(UBound(strTransDate) + 1)
ReDim Preserve objCheckNum(UBound(objCheckNum) + 1)
ReDim Preserve strPayee(UBound(strPayee) + 1)
ReDim Preserve strPurpose(UBound(strPurpose) + 1)
ReDim Preserve intAmount(UBound(intAmount) + 1)
sglAmount = Convert.ToSingle(txtAmount.Text)
'* Accumulate transaction count
ReDim Preserve intItemCount(UBound(intItemCount) + 1)
intItemCount(UBound(intItemCount)) = 1
'* Perform calculations
If radDeposit.Checked = True Then '* Transaction is a deposit
'* Accumulate totals
sglBalance += txtAmount.Text
Dim x As Integer = 0, i As Integer = 0
For i = 0 To intDepositAmount.GetUpperBound(0)
sglDepositAmount += intDepositAmount(i)
Next
Else '* Transaction is a check
'* Accumulate totals
sglBalance -= txtAmount.Text
Dim x As Integer = 0, i As Integer = 0
For i = 0 To intDepositAmount.GetUpperBound(0)
sglCheckAmount += intCheckAmount(i)
Next
End If '* End of transaction type test
'*
'* Display accumulated totals
'*
'* Overall totals
lblBalance.Text = FormatNumber(sglBalance, 2)
lblNumOfItems.Text = intItemCount.Length
'* Check totals
lblValueOfChecks.Text = FormatNumber(sglCheckAmount, 2)
lblNumOfChecks.Text = intCheckAmount.Length
'* Deposit totals
lblValueOfDeposits.Text = FormatNumber(sglDepositAmount, 2)
lblNumOfDeposits.Text = intDepositAmount.Length
'* Transfer input values to display labels
If radDeposit.Checked = True Then
lblType.Text = "Deposit"
Else
lblType.Text = "Check"
End If
lblTransDate.Text = dtpTransDate.Text
lblCheckNum.Text = txtCheck.Text
lblPayee.Text = txtPayee.Text
lblPurpose.Text = txtPurpose.Text
lblAmount.Text = FormatNumber(sglAmount, 2)
'* Reset input controls
'* Leaves transaction date at last value
radCheck.Checked = False
radDeposit.Checked = False
txtCheck.Text = ""
txtPayee.Text = ""
txtPurpose.Text = ""
txtAmount.Text = ""
'* Notify user of success
lblHelp.Text = "Transaction processed successfully"
End If '* End of processing for valid entries
My balance always comes out right and so does total number of items.. but my running totals for the checks and deposits come out to zero.. Please someone help! =) Thank you!
Private Sub LoadArrayElements()
strTransDate(UBound(strTransDate)) = dtpTransDate.ToString
objCheckNum(UBound(objCheckNum)) = txtCheck.Text
strPayee(UBound(strPayee)) = txtPayee.Text
strPurpose(UBound(strPurpose)) = txtPurpose.Text
End Sub
Call LoadArrayElements()
'*Redim arrays to add new element
ReDim Preserve strTransDate(UBound(strTransDate) + 1)
ReDim Preserve objCheckNum(UBound(objCheckNum) + 1)
ReDim Preserve strPayee(UBound(strPayee) + 1)
ReDim Preserve strPurpose(UBound(strPurpose) + 1)
ReDim Preserve intAmount(UBound(intAmount) + 1)
sglAmount = Convert.ToSingle(txtAmount.Text)
'* Accumulate transaction count
ReDim Preserve intItemCount(UBound(intItemCount) + 1)
intItemCount(UBound(intItemCount)) = 1
'* Perform calculations
If radDeposit.Checked = True Then '* Transaction is a deposit
'* Accumulate totals
sglBalance += txtAmount.Text
Dim x As Integer = 0, i As Integer = 0
For i = 0 To intDepositAmount.GetUpperBound(0)
sglDepositAmount += intDepositAmount(i)
Next
Else '* Transaction is a check
'* Accumulate totals
sglBalance -= txtAmount.Text
Dim x As Integer = 0, i As Integer = 0
For i = 0 To intDepositAmount.GetUpperBound(0)
sglCheckAmount += intCheckAmount(i)
Next
End If '* End of transaction type test
'*
'* Display accumulated totals
'*
'* Overall totals
lblBalance.Text = FormatNumber(sglBalance, 2)
lblNumOfItems.Text = intItemCount.Length
'* Check totals
lblValueOfChecks.Text = FormatNumber(sglCheckAmount, 2)
lblNumOfChecks.Text = intCheckAmount.Length
'* Deposit totals
lblValueOfDeposits.Text = FormatNumber(sglDepositAmount, 2)
lblNumOfDeposits.Text = intDepositAmount.Length
'* Transfer input values to display labels
If radDeposit.Checked = True Then
lblType.Text = "Deposit"
Else
lblType.Text = "Check"
End If
lblTransDate.Text = dtpTransDate.Text
lblCheckNum.Text = txtCheck.Text
lblPayee.Text = txtPayee.Text
lblPurpose.Text = txtPurpose.Text
lblAmount.Text = FormatNumber(sglAmount, 2)
'* Reset input controls
'* Leaves transaction date at last value
radCheck.Checked = False
radDeposit.Checked = False
txtCheck.Text = ""
txtPayee.Text = ""
txtPurpose.Text = ""
txtAmount.Text = ""
'* Notify user of success
lblHelp.Text = "Transaction processed successfully"
End If '* End of processing for valid entries
My balance always comes out right and so does total number of items.. but my running totals for the checks and deposits come out to zero.. Please someone help! =) Thank you!
![]() |
Similar Threads
- Arrays and if/else statements - trying to get them to work with URLs (PHP)
- How do I write a C++ program that converts from 24-hour notation to 12-hour notation? (C++)
- Please provide me answers of the following questions (C++)
- what's wrong eith my coding? (Java)
- Finding the lowest of five test scores (C++)
- Help in counting (Python)
- Trying to use pointers (C++)
- build table used 2d arrays (C)
Other Threads in the VB.NET Forum
- Previous Thread: Need help taking numbers from inputbox to textbox
- Next Thread: mdi child maximize, form tiling, and alignment of controls
| Thread Tools | Search this Thread |
.net .net2008 access activex add algorithm analyst angle array arrays basic binarysearchtree browser buttons c# c++ cast char character click component conversion creat cuil database decimal degrees delete development drawing dropdown dynamic equation file form frequency function gdi+ graph html image inboxinvb index int intersect java javascript list listbox mandelbrot math mathematics menu multidimensional mysql number numbers output perl php picturebox plotting pointer polynomial position prime programmer python radians random record recursion reference regex save scanner search sequential split statistics string survey table technology time txt upload usb values vb vb.net vb6 vbnet vista visualbasic visualbasic.net visualstudio web windows wpf






