Eliminating Unwanted Lines numeric value #2

T

TrudyL

Guess I spoke too soon. The data is formatted correctly but the 2nd line is
blank. Any suggestions. TrudyL
 
D

Douglas J Steele

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.
 
T

TrudyL

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
 
D

Douglas J. Steele

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
 
T

TrudyL

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top