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 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!!!
 
hard to be sure, BUT ...

Val is generally used to get the value (number thing) from a text variable. If your col eight in the matrix is 'seen' as text with the format including the thousands seperator, the comma is 'seen' as the ene delimiter of the value part of the text and thus (only) the nemeric preceeding the "comma" is interperted". Consider the following:

? val("2,000"), Val("$1678.98"), Val("1,678.98")
2 0 1

then contemplate this approach:

? Csng("1678.98"), CSng("2134.79"), CSng("$2134.79")
1678.98 2134.79 2134.79




MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Thanks MichaelRed for putting me in perspective. I still have a little hair left thanks to you. Every day above ground is a GOOD DAY!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top