Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Trimming characters

Posted on 2013-06-19
4
Medium Priority
?
325 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

971 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