Eliminating Unwanted Lines numeric value #2

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Guess I spoke too soon. The data is formatted correctly but the 2nd line is
blank. Any suggestions. TrudyL
 
That makes it sounds as though there was only one value then. Sal's code
could use an improvement.

After the loop, add:

If Len(strLine) > 0 Then
strLine = Left$(strLine, Len(strLine) - 2))
End If

That'll remove the final carriage return/line feed.
 
Now both the amounts are on the same line. I must have referenced the wrong
code to you. The code for "text" shrink is:
Public Function CanShrinkLines(ParamArray arrLines())
Dim x As Integer, strLine As String
For x = 0 To UBound(arrLines)
If Not IsNull(arrLines(x)) And arrLines(x) <> "" Then
strLine = strLine & arrLines(x) & vbCrLf
End If
Next
CanShrinkLines = strLine
End Function
The text works and drops the lines. Since I have both text and currency
columns I also made a currency module. It reads as follows:
Public Function CanShrinkCurrency(ParamArray arrLines())

Dim x As Integer, strLine As String
For x = 0 To UBound(arrLines)

If Not IsNull(arrLines(x)) And arrLines(x) <> "" Then

strLine = strLine & Format(arrLines(x), "Currency") & vbCrLf
If Len(strLine) > 0 Then
strLine = Left$(strLine, Len(strLine) - 2)
End If
End If
Next
CanShrinkCurrency = strLine
End Function
Hope you can figure out what is wrong. thanks TrudyL
 
You've put the new logic in the wrong place. As I said, it has to go after
the loop:

Public Function CanShrinkLines(ParamArray arrLines())
Dim x As Integer, strLine As String

For x = 0 To UBound(arrLines)
If Not IsNull(arrLines(x)) And arrLines(x) <> "" Then
strLine = strLine & Format(arrLines(x), "Currency") & vbCrLf
End If
Next
If Len(strLine) > 0 Then
strLine = Left$(strLine, Len(strLine) - 2)
End If
CanShrinkCurrency = strLine

End Function
 
My Report works fine now. Thanks
--
TrudyL


Douglas J. Steele said:
You've put the new logic in the wrong place. As I said, it has to go after
the loop:

Public Function CanShrinkLines(ParamArray arrLines())
Dim x As Integer, strLine As String

For x = 0 To UBound(arrLines)
If Not IsNull(arrLines(x)) And arrLines(x) <> "" Then
strLine = strLine & Format(arrLines(x), "Currency") & vbCrLf
End If
Next
If Len(strLine) > 0 Then
strLine = Left$(strLine, Len(strLine) - 2)
End If
CanShrinkCurrency = strLine

End Function
 
Back
Top