It looks like you're new here. If you want to get involved, click one of these buttons!

- 69.7K All Categories
- 73 General
- 73 Announcements
- 63.9K Microsoft Dynamics NAV
- 16.5K NAV Three Tier
- 38.1K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 112 Navision DOS
- 846 Navision e-Commerce
- 866 NAV Tips & Tricks
- 766 NAV Dutch speaking only
- 608 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 223 Dynamics CRM
- 107 Dynamics GP
- 9 Dynamics SL
- 1.5K Other
- 970 SQL General
- 379 SQL Performance
- 30 SQL Tips & Tricks
- 23 Design Patterns (General & Best Practices)
- Architectural Patterns
- 6 Design Patterns
- 3 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 78 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

mickbarrs
Member Posts: **17**

I'm trying to find the position of the first value that is not a numeric value within a string.

pTxtNumber is passed in and could be**10-15672** for example. So I want to return position 3 because this is the first non numeric character. Then I want to chop of the string up to and including this character so that I am left with **15672**.

This code i initially did checks for where the numeric value begins but now i want to do the opposit.

FOR i := 1 TO STRLEN(pTxtNumber) DO BEGIN

IF Pos = 0 THEN

IF FORMAT(pTxtNumber*) IN THEN*

Pos := i;

END;

Any help would be greatly appreciated.

Cheers

Mike

pTxtNumber is passed in and could be

This code i initially did checks for where the numeric value begins but now i want to do the opposit.

FOR i := 1 TO STRLEN(pTxtNumber) DO BEGIN

IF Pos = 0 THEN

IF FORMAT(pTxtNumber

Pos := i;

END;

Any help would be greatly appreciated.

Cheers

Mike

0

## Comments

429IF FORMAT(pTxtNumber

) IN THEN

put

IF NOT (FORMAT(pTxtNumber

) IN ) THEN

I think it could work ...

17IF FORMAT(pTxtNumber

) NOT IN THEN

and this did not work either.

I suppose i could enter into a substring 'abcdefg-!"£$%^&*' etc and then check in my string to see if it contains any of the characters in the substring but i thought there might be a more efficient way of saying find the first non-numeric character.

Any ideas?

8,875No PM,please use the forum. || May the <SOLVED>-attribute be in your title!

NAV TechDays 2020: 19 & 20 November 2020, Antwerp (Belgium)

8,163<edit>so that still doesn't give you the position of the first non numeric character..... let me think about that</edit>

Daniel RimmelzwaanRIS Plus, LLC

MVP - Dynamics NAV

8,163TargetString - Text30

IFoundIt - boolean

MyPos - Integer That should find the first non-numeric character in SourceString. So then you wrap it in a function and use return value.

Daniel RimmelzwaanRIS Plus, LLC

MVP - Dynamics NAV

1488,163Daniel RimmelzwaanRIS Plus, LLC

MVP - Dynamics NAV

148AsciiNo is integer

mystr is text

Message returns 48 which is ASCII No. for 0 (zero)

12,562That's all folks... 8)

MVP - Dynamics NAV

My BLOG

NAVERTICA a.s.

8,163Daniel RimmelzwaanRIS Plus, LLC

MVP - Dynamics NAV

17= FALSEto the second line. This then tells me the line number where the first non-numeric character is.FOR i := 1 TO STRLEN(pTxtNumber) DO BEGIN

IF FORMAT(pTxtNumber

) IN = FALSE THEN

Pos := i;

END;

IntNumber := 0;

IF Pos <> 0 THEN BEGIN

Alpha := DELSTR(pTxtNumber, 1, Pos);

EVALUATE(IntNumber, Alpha);

END;

EXIT(IntNumber);

Thanks for the help!!!

Mike

8,163Daniel RimmelzwaanRIS Plus, LLC

MVP - Dynamics NAV

17I just wanted to take the part of the string after the non-numeric character which in this case is '-'. So i wanted to return 98765.

mystr := '10-98765';

FOR i := 1 TO STRLEN(mystr) DO BEGIN

IF NOT (mystr

IN [48..57]) THEN BEGIN // ascii for 0 thru 9

newstr := COPYSTR(mystr,i+1);

i := STRLEN(mystr); // drops out of for statement

END;

END;

MESSAGE('%1',newstr)

8,163Daniel RimmelzwaanRIS Plus, LLC

MVP - Dynamics NAV

1738,163Daniel RimmelzwaanRIS Plus, LLC

MVP - Dynamics NAV