I have a forumla {@.frmPrevMonth} and it contains information like... "21,36.02,11141.75,1" which it came from a Parameter field.
It can contain more of less information.
What I need is that it can be broke down in order in which they came.
1st Detail line: 21
2nd Detail line: 36.02
3rd Detail line: 11141.75
4th Detail line: 1
How can I achive this?You are going to use the left(), Mid(), and right() functions.
You will have 4 formulas.
This will work for the number you show.
1. Left({@.frmPrevMonth} ,2) // gets 21
2. Mid({@.frmPrevMonth} ,4,5) // gets 36.02
3. Mid({@.frmPrevMonth} 10,8) // gets 11141.75
4. Right({@.frmPrevMonth} ,1) // gets 1
GJ|||I forgot to put down that the numbers vary in size and it is not always 4 things I need. It can be a total of 10 lines or 1 line.|||Ok here is a formula that will get the first strings before the first comma.
I assume you want the values between the commas.
'This formula uses Basic syntax
dim StringInput as string
dim Character as string
dim NumberOfCharacters as number
'The StringInput, Character and NumberOfCharacters
'variables can be changed to your values
StringInput = {@.Number}
Character = ","
NumberOfCharacters = 0
'NumberOfCharacters specifies that the token returned
'If the token to be retrieved comes before the first
'occurrence of Character, use 0 for NumberOfCharacters.
dim Token as number
dim Increment as number
dim Output as string
dim Ender as number
Ender = NumberOfCharacters + 1
do until Token = Ender or Increment = length(StringInput)
Increment = Increment + 1
if StringInput(Increment) = Character then Token= Token + 1
if Ender - Token = 1 and StringInput(Increment) <> Character then Output = Output + StringInput(Increment)
loop
Formula = Output
If you could have up to 10 lines then you will have 10 formulas the way I show, just change the variable at NumberOfCharacters. 1st formula has a 0, 2nd would have a 1 and up to 9 for 10 lines.
Hope that makes sense, someone else might have an easier way of doing this.
GJ|||Look at the help for the Split function, and on arrays.
e.g.
stringvar array parts := split({table.field}); //or maybe numbervar, if all your parts are numbers
parts[2] //return the 2nd part|||Oops, meant to add the 2nd parameter to the split function:
split({table.field}, ',');|||I tried the split function.
Attached is what I am looking for. Thanks.|||Ok here is a formula that will get the first strings before the first comma.
I assume you want the values between the commas.
'This formula uses Basic syntax
dim StringInput as string
dim Character as string
dim NumberOfCharacters as number
'The StringInput, Character and NumberOfCharacters
'variables can be changed to your values
StringInput = {@.Number}
Character = ","
NumberOfCharacters = 0
'NumberOfCharacters specifies that the token returned
'If the token to be retrieved comes before the first
'occurrence of Character, use 0 for NumberOfCharacters.
dim Token as number
dim Increment as number
dim Output as string
dim Ender as number
Ender = NumberOfCharacters + 1
do until Token = Ender or Increment = length(StringInput)
Increment = Increment + 1
if StringInput(Increment) = Character then Token= Token + 1
if Ender - Token = 1 and StringInput(Increment) <> Character then Output = Output + StringInput(Increment)
loop
Formula = Output
If you could have up to 10 lines then you will have 10 formulas the way I show, just change the variable at NumberOfCharacters. 1st formula has a 0, 2nd would have a 1 and up to 9 for 10 lines.
Hope that makes sense, someone else might have an easier way of doing this.
GJ
ok. how can I dynamically increase the "NumberOfCharacters" after everytime a record is read and then have it display it on the detail line?|||Have not had time today to work formula. Why not use the split function like JaganEllis suggested. It's quicker and easier to understand.
GJ|||An example to produce what I think you want:
local stringvar a := "21,36.02,11141.75,1";
local stringvar array parts := split(a, ',');
local numbervar i;
local stringvar out;
for i := 1 to ubound(parts) do
(
out := out + parts[i] + chr(13) + chr(10);
);
out
And remember to check the 'Can Grow' option for the field, in the Common tab of the Format Field option.
Showing posts with label contain. Show all posts
Showing posts with label contain. Show all posts
Monday, March 19, 2012
Friday, March 9, 2012
Limiting Amount of Text in a box
I have Comments field in my db that can contain many lines of text and when
it displays in the report the textbox grow extensively. How can I limit the
amount that the text box grows, OR limit the amount of text that is
retrieved in my query, i.e., I only want to display 10-15 lines out of
potentially 80-100.
Thanks
DeanYou can try to show only the first N characters doing it in your SQL
sentence or in the Cell Expresion:
IN SQL:
SELECT substring(YourtextField, 1, N) as Comments, ... FROM YourTable
IN Your cell expresion:
= Mid(Fields!YourField.Value, 1, N)
Does it help?
"Dean" <deanl144@.hotmail.com.nospam> escribió en el mensaje
news:%23M8giJhIIHA.5764@.TK2MSFTNGP06.phx.gbl...
>I have Comments field in my db that can contain many lines of text and when
>it displays in the report the textbox grow extensively. How can I limit the
>amount that the text box grows, OR limit the amount of text that is
>retrieved in my query, i.e., I only want to display 10-15 lines out of
>potentially 80-100.
> Thanks
> Dean
>|||On Nov 8, 9:19 am, "Dean" <deanl...@.hotmail.com.nospam> wrote:
> I have Comments field in my db that can contain many lines of text and when
> it displays in the report the textbox grow extensively. How can I limit the
> amount that the text box grows, OR limit the amount of text that is
> retrieved in my query, i.e., I only want to display 10-15 lines out of
> potentially 80-100.
> Thanks
> Dean
You could create a custom code that counts the carriage return
characters (vbCr, vbLf, vbCrLf depending on your encoding), and if
there are more than 10 in your input string, truncate it using the
Left function
Off the top of my head, it would look something like this:
Function TextTrimmer( txt As String ) As String
lineCount = 0
returnOffset = 1
While lineCount < 10 and returnOffset > 0
returnOffset = InStr( returnOffset+1, txt, vbCr)
lineCount = lineCount + 1
Wend
If returnOffset = 0 Then
' ran out of characters in the string before reaching 10 lines
return( txt )
Else
return( Left( txt, returnOffset-1 ) & "..." )
End If
End Function
Then in the textbox, use
=Code.TextTrimmer( Fields!ReallyLongText.Value )
-- Scott
it displays in the report the textbox grow extensively. How can I limit the
amount that the text box grows, OR limit the amount of text that is
retrieved in my query, i.e., I only want to display 10-15 lines out of
potentially 80-100.
Thanks
DeanYou can try to show only the first N characters doing it in your SQL
sentence or in the Cell Expresion:
IN SQL:
SELECT substring(YourtextField, 1, N) as Comments, ... FROM YourTable
IN Your cell expresion:
= Mid(Fields!YourField.Value, 1, N)
Does it help?
"Dean" <deanl144@.hotmail.com.nospam> escribió en el mensaje
news:%23M8giJhIIHA.5764@.TK2MSFTNGP06.phx.gbl...
>I have Comments field in my db that can contain many lines of text and when
>it displays in the report the textbox grow extensively. How can I limit the
>amount that the text box grows, OR limit the amount of text that is
>retrieved in my query, i.e., I only want to display 10-15 lines out of
>potentially 80-100.
> Thanks
> Dean
>|||On Nov 8, 9:19 am, "Dean" <deanl...@.hotmail.com.nospam> wrote:
> I have Comments field in my db that can contain many lines of text and when
> it displays in the report the textbox grow extensively. How can I limit the
> amount that the text box grows, OR limit the amount of text that is
> retrieved in my query, i.e., I only want to display 10-15 lines out of
> potentially 80-100.
> Thanks
> Dean
You could create a custom code that counts the carriage return
characters (vbCr, vbLf, vbCrLf depending on your encoding), and if
there are more than 10 in your input string, truncate it using the
Left function
Off the top of my head, it would look something like this:
Function TextTrimmer( txt As String ) As String
lineCount = 0
returnOffset = 1
While lineCount < 10 and returnOffset > 0
returnOffset = InStr( returnOffset+1, txt, vbCr)
lineCount = lineCount + 1
Wend
If returnOffset = 0 Then
' ran out of characters in the string before reaching 10 lines
return( txt )
Else
return( Left( txt, returnOffset-1 ) & "..." )
End If
End Function
Then in the textbox, use
=Code.TextTrimmer( Fields!ReallyLongText.Value )
-- Scott
Subscribe to:
Posts (Atom)