Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1384
  • Last Modified:

Find Line Feed / Carriage Return

Have formula in Crystal Report trided this code; received error in formula message. trying to locate the position in the string where carriage return is located, I know in the test record it is postion 15. I am learn this code need help isolating the problem

   Dim intPos         As Integer;
   Dim strString      As String;

   intPos = InStr({ODLN.Address},Chr(13))
   strstring = left({ODLN.Address}, intPos - 1)
0
johntmcii
Asked:
johntmcii
  • 6
  • 4
  • 4
2 Solutions
 
BostonMACommented:
What does the error message say?
0
 
johntmciiAuthor Commented:
Error in formula Do you want to save anyway?  I answer yes then refresh... says....... remaining text does not appear to be part of the formula
0
 
johntmciiAuthor Commented:
I This is the file I am using. Found it has address, city state and country in one file, seperated by one or more sets of Od/Oa. I am trying to find the end of the first field then I will find the beginning of the second field etc
The code I sent was only the first part where I got the error

datafile.bmp
0
Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

 
BostonMACommented:
Can you try commenting out everything else in the formula except what you sent us? And then try saving it.  The problem sounds like its from another part of the formula...
0
 
johntmciiAuthor Commented:
This is all I have in the formula, this time received second message

error1.bmp
error2.bmp
0
 
johntmciiAuthor Commented:
I think the difference is it was set for Crystal syntax vs Bsic syntax; in either case I go no results
0
 
BostonMACommented:
Well if you switch to crystal syntax  and use:

local Numbervar intPos;
local Stringvar strString;


intPos = InStr({ODLN.Address},Chr(13));
strstring = left({ODLN.Address}, intPos - 1);

it should work?!
0
 
mlmccCommented:
Crystal syntax uses := for assignment and = for comparison.
Change the = to a :=

local Numbervar intPos;
local Stringvar strString;

intPos := InStr({ODLN.Address},Chr(13));
strstring := left({ODLN.Address}, intPos - 1);

mlmcc
0
 
johntmciiAuthor Commented:
Sorry, it don't....... The remaining text does not appear to be part of the formula....same error as original same results.
0
 
mlmccCommented:
In basic syntax there are no ; at the end of lines.  Your declarations have ;'s

mlmcc
0
 
mlmccCommented:
What is highlighted when you get the error?

mlmcc
0
 
johntmciiAuthor Commented:
The difference in the two error messages was a result of one being in Basic Syntax mode and the other message being in Crystal Syntax mode. When I run this in Crystal Syntax mode I get the same original message, if I change to run in basic mode it will get the other error I sent.  
0
 
mlmccCommented:
I see my comments got intrrupted

Crystal syntax for your form,ula

local Numbervar intPos;
local Stringvar strString;

intPos := InStr({ODLN.Address},Chr(13));
strstring := left({ODLN.Address}, intPos - 1);

Basic Syntax
   Dim intPos         As Integer
   Dim strString      As String

   intPos = InStr({ODLN.Address},Chr(13))
   strstring = left({ODLN.Address}, intPos - 1)
   formula = strstring

mlmc
0
 
BostonMACommented:
local Numbervar intPos;
local Stringvar strString;

intPos := InStr({ODLN.Address},Chr(13));
strstring := left({ODLN.Address}, intPos - 1);

This does work in crystal i just tried it
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 6
  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now