Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't this statement work??

Status
Not open for further replies.

rtshort

IS-IT--Management
Feb 28, 2001
878
US
I tried using this and it will not work. If the extended amount is over $1,000.00(any amount even like $1678.98) it only adds $1.00 to the txtPartsTotal.Text. If it's over $2000.00 it adds $2.00.

Public Sub GetPartsTotal()
Dim i As Integer
Dim Parts As Currency
For i = 1 To flexDA.Rows - 1
Parts = Parts + Val(flexDA.TextMatrix(i, 8))
txtPartsTotal.Text = Format(Parts, "Currency")
Next i
End Sub

Col(8) is the extended amount column. It is arrived at by the following formula. (Col(4) is the Part Price column and txtQuantity is the item quantity purchased.)

Flex1.Additem Format(cboQuantity.Text * flexChoose.TextMatrix(i, 4), "Currency")

This statement work correctly.

I can't figure out why the first statement will not??? Please help me. I'm pulling my hair out. Every day above ground is a GOOD DAY!!!
 
Val function stops a comma?
Val is old, old going away daid back to '60s and I was there basic so don't use it.
CCur(Replace(flexDA.TextMatrix(i, 8),"$",""))
 
Val function stops at a comma?
Val is old, old going away daid back to '60s and I was there basic so don't use it.
CCur(Replace(flexDA.TextMatrix(i, 8),"$",""))
Accepts leading or trailing sign characters.
 
Thanks John. I'm new at this and that's a news to me. I'll give it a try. Every day above ground is a GOOD DAY!!!
 
From the VB docs. When all fails read the instructions
Libraries /MSDN
or place the cursor on the word you want to look up up and press F1, assuming you installed the MSDN that came with VS (and I assume VB).
"Val(string)

The required string argument is any valid string expression.

Remarks

The Val function stops reading the string at the first character it can't recognize as part of a number. Symbols and characters that are often considered parts of numeric values, such as dollar signs and commas, are not recognized. However, the function recognizes the radix prefixes &O (for octal) and &H (for hexadecimal). Blanks, tabs, and linefeed characters are stripped from the argument."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top