Solved

Trimming characters

Posted on 2013-06-19
4
322 Views
Last Modified: 2013-06-25
I have a 2010 Microsoft Access database which has the following code that parses a text field:  

"TROPONIN-I/CTNI                                   <0.03    ng/mL"

s = Split(LabPaste, "TROPONIN-I/CTNI  ")
If UBound(s) > 0 Then
strLab = Split(Trim(s(1)), " ")(0)
strLab2 = Split(Trim(s(1)), " ")(1)
If (strLab = "<" Or strLab = ">") Then
Text863 = strLab
Text657 = strLab2
Else
Text863 = ""
Text657 = strLab
End If
Else
End If

Open in new window


The problem is that I get an error because there is no space between the "<" and the "0.03".  I need to trim off the "<" somehow and return only "0.03"

Any help would be greatly appreciated!
0
Comment
Question by:Drjdh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 96

Expert Comment

by:Lee W, MVP
ID: 39261137
I'm not sure where or why you're getting that error, but you can use Replace -

Replace(StringOrField, "<", "")

You're replaceing "<" with "" (empty/nothing)
0
 

Author Comment

by:Drjdh
ID: 39261153
I actually want to keep the "<" and place that in a field.  In the above code, if "<" is present, then it is stored in control Text863.
0
 

Accepted Solution

by:
Drjdh earned 0 total points
ID: 39264826
Here is the solution for those of you interested:

s = Split(LabPaste, "TROPONIN-I/CTNI  ")
If UBound(s) > 0 Then
strLab = Split(Trim(s(1)), " ")(0)
strLab2 = Split(Trim(s(1)), " ")(1)
Text901 = Trim(s(1))
Text902 = strLab
Text903 = IIf(InStr(strLab, "<") > 0, "<", IIf(InStr(strLab, ">") > 0, ">", ""))
Text904 = IIf(InStr(strLab, "<") > 0, Val(Mid(LabPaste, InStr(LabPaste, "<") + 1)), IIf(InStr(strLab, ">") > 0, Val(Mid(LabPaste, InStr(LabPaste, ">") + 1)), strLab))

Open in new window

0
 

Author Closing Comment

by:Drjdh
ID: 39274212
This "InStr" function was the key to this one.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question