SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 6 of 6
  1. #1
    Member apchinni's Avatar
    Join Date
    Jun 2005
    Location
    SLC
    Posts
    85
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Issue with a Function

    I have been using following function to find a value between two words. It returns correct value when I have no duplicate words but in the opposite case this function returns me incorrect value.
    Function ParseScreenVal(varString,varCurr,varNext)
    i = varString
    i = CStr(i)
    varCount = instr( 1,i,varCurr,vbTextCompare)
    varCount2 = instr( 1,i,varNext,vbTextCompare)
    ParseScreenVal = Mid(i, varCount + len(varCurr),varCount2-varCount - len(varCurr))

    End Function


    Please see the attachment for more details. Any help would be really appreciated

    Thanks in advance
    Attached Files Attached Files

  2. #2
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Issue with a Function

    Change this

    varCount = instr( 1,i,varCurr,vbTextCompare)
    varCount2 = instr( 1,i,varNext,vbTextCompare)

    to

    varCount = instr( 1,i,varCurr,vbTextCompare)
    varCount2 = instr( varCount + Len(varCurr),i,varNext,vbTextCompare)

    And see if that helps

  3. #3
    Member apchinni's Avatar
    Join Date
    Jun 2005
    Location
    SLC
    Posts
    85
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Issue with a Function

    Tarun,

    Thanks for your reply. I followed your suggestions but still returns an incorrect value. I have updated the attached document to give better idea on the error/issue. Please look at the document.

    Also I tried to use FilterStr function from your book but that did not match to this scenario.

    Once again thanks for your time.
    Attached Files Attached Files

  4. #4
    Moderator
    Join Date
    Jan 2007
    Location
    Pittsburgh, PA
    Posts
    2,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Issue with a Function

    RegExp is the best option to get desired text portion in your case.

    Sample code here, you will need to improve it with proper error handling. <font class="small">Code:</font><hr /><pre> MyVar = "Considered Charge$0.00Deductible$0.00Discount Amount$0.00Supplemental DiscountAllowed Units0Copay$0.00$0.00COB AdjustmentAllowed$0.00Coinsurance$0.00$0.00Withhol d AmountBenefit$0.00Disallow$0.00$0.00Patient Liability Disallow$0.00$0.00HRA PaidTotal Patient Liability$0.00$0.00FSA PaidType of ServiceNetwork IndicatorPlace of ServiceLine of BusinessProcedureDiagnosisSourceReferralNoReferral IDNonePreauthNoPreauth IDWaived PreauthNoNDC UnitsNational Drug CodeFund IDMiscellaneous Data"

    Function RegExpTest(patrn, strng)
    Dim regEx, Match, Matches ' Create variable.
    Set regEx = New RegExp ' Create a regular expression.
    regEx.Pattern = patrn ' Set pattern.
    regEx.IgnoreCase = True ' Set case insensitivity.
    regEx.Global = True ' Set global applicability.
    Set Matches = regEx.Execute(strng) ' Execute search.
    If Matches.Count &gt; 0 Then
    RegExpTest = Matches.Item(0)
    End If
    End Function
    MsgBox(RegExpTest("Allowed\$[0-9]{1,}\.[0-9]{2}", MyVar))
    Msgbox Split(RegExpTest("Allowed\$[0-9]{1,}\.[0-9]{2}", MyVar),"$")(1)
    </pre><hr />

  5. #5
    Advanced Member
    Join Date
    Aug 2006
    Location
    Other side of the Computer
    Posts
    598
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Issue with a Function

    you could do few things here.

    1) look at the object property there might me an id or something other thing that you could use to identify.
    2) loop through the table so you can get the exact item.
    ===========================================

  6. #6
    Member apchinni's Avatar
    Join Date
    Jun 2005
    Location
    SLC
    Posts
    85
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Issue with a Function

    TReddy,

    RegExp magic worked for me. I have created different patterns for Alphanumeric, numeric only and strings. I am working on error handling and also to trim the out put text but your idea solved my problem.

    Thank you very much.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.34%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:10 AM.

Copyright BetaSoft Inc.