Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help on this function
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
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.
Code:
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
.doc   Issue with Pane.doc (Size: 57.5 KB / Downloads: 106)
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi,
Really i have spent more than 2 hours and finally i have get the conclusion
use this function

Code:
Function fbtwds(p,p1,p2)
l=len(p)
l1=len(p1)
l2=len(p2)
if1=instr(1,p,p1)
m=right(p,l-(if1+l1-1))
m=trim(m)
ml=len(m)
if2=instr(1,m,p2)
m=left(m,if2-1)
msgbox m
End Function
call fbtwds("abdul kalam is scinetist and former president","kala","and")
incase if u have duplicates in a variable "p" then proceed the same operation until u get the correct one....

Please let me know if i am going in wrong direction..
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
Hi Venkat,
Thanks for your time on this. I tried your function but still returns me an incorrect value. Please see the attachment with updated info on this issue. Please let me know if you have any other ideas to get the correct value.
Once again thanks for your help.


Attached Files
.doc   Issue with Pane_1.doc (Size: 52 KB / Downloads: 68)
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
hi faqtest2009,
I have modified your code, check out if this works
Code:
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))
sResult = Mid(i, varCount + len(varCurr),varCount2-varCount - len(varCurr))
Do
    varCount = instr( 1,sResult,varCurr,vbTextCompare)
    If varCount > 0Then
        sResult  = Mid(sResult, varCount + len(varCurr),len(sResult))
    End If
Loop while  varCount > 0
ParseScreenVal = sResult
End Function
I have verified with the data in your attachment.
let me know if you find any issue with other data.

@Everyone - Please use proper tags to wrap your code and make your post readable.

Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
Thank you very much, it works for me with the given text.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,973 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  How can I fetch server time using function Now or any other function? blanchedsouza 2 5,115 11-07-2009, 08:34 PM
Last Post: Ankur

Forum Jump:


Users browsing this thread: 1 Guest(s)