Rob,

You need to set GetPriceTextout to the value that you want it to return in the 
function before you exit it.  Something like GetPriceTextout = ReturnValue in 
your Do ... Loop before the Exit Function call.  See the example below.

Function GetPriceTextOut(x As String, y As String) As String
...
        If TOut.Filtered Then
           Debug.Print TOut.x, TOut.y, TOut.TextOutString
           ' This line stores the value on the screen to a variable.
            yourvalue = TOut.TextOutString
            GetTextout = TOut.TextOutString

            ' Set the value of the function
            GetPriceTextout = GetTextout

           Exit Function
        End If
...
  If Loops > 10 Then
    'MsgBox ("I didn't find anything")

    ' If there is no data, you can return something like this
    ' and then check for it in the calling routine
    GetPriceTextout = "No Records"

    Exit Function
  End If
End Function

Regards,
Jeff
________________________________
From: [email protected] [[email protected]]
Sent: Monday, May 10, 2010 6:04 PM
To: [email protected]
Subject: [talkbws] Return Value from Textout Windows Application

Hello Everyone,

I’m trying to get a value from the below function and pass it to strPrice.  
What’s weird is I the function itself will show the value but it is not 
returning to strPrice.  Not sure what I am doing wrong.

I would appreciate any suggestions.  Thanks.


Sub FindPrice()

Dim strPrice As String
Connect "BPE Batch Payment Entry - Affinity", stWindows
strPrice = GetPriceTextout(582, 63)

End Sub
------------------------------------------------------------------------------------------------------------------------------------------
Function GetPriceTextout(x As String, y As String) As String

Dim TOut As New CTextout
Dim yourvalue As String
Connect "BPE Batch Payment Entry - Affinity", stWindows
Key "@_LOGON"   ' Dipping into the screen output.
Set TOut.w = R
' Clearing the prior text out string
TOut.LikeTextOutString = ""
' Setting the filter stuff.  Not really necessary
TOut.LikeX = x
TOut.LikeY = y
' This is an infinite loop.  You want to modify the script so it will jump out
' Once it finds what it's looking for.

' You might want to put some logic in to handle a possible situation
' were the x and y are never found.
Dim Loops As Integer
Loops = 0
Do
    Loops = Loops + 1
    View B:=bcTextOutNoClear
    ' This inner loop is saying search through the buffered up information for
    ' The information I'm looking for.
    Do Until TOut.IsEmpty
        TOut.NextTextOut
        If TOut.Filtered Then
           Debug.Print TOut.x, TOut.y, TOut.TextOutString
           ' This line stores the value on the screen to a variable.
            yourvalue = TOut.TextOutString
            GetTextout = TOut.TextOutString

           Exit Function
        End If
        If TOut.x = "582" And TOut.y = "63" Then
           ' Insert stuff here.
        End If
    Loop
    Wait 0.2
    'TOut.ReDraw
    RePaint
Loop Until Loops > 10
If Loops > 10 Then
   'MsgBox ("I didn't find anything")
Exit Function
End If
End Function

Rob McGinness, Information Services
Interface Programmer/Analyst
Rutland Regional Medical Center
160 Allen St,  Rutland VT 05701
P 802.747.6526  F 802.773.7576
[email protected]<mailto:[email protected]>   
www.rrmc.org<http://www.rrmc.org/>

Our Vision:
To be the Best Community Hospital and Health System in New England

This message (and any included attachments) is from Rutland Regional Health 
Services and is intended only for the addressee(s). The information contained 
herein may include privileged or otherwise confidential information. 
Unauthorized review, forwarding, printing, copying, distributing, or using such 
information is strictly prohibited and may be unlawful. If you received this 
message in error, or have reason to believe you are not authorized to receive 
it, please promptly delete this message and notify the sender by e-mail.

Thank You


---  To post a message to this list, send mail to: [email protected]    You are 
currently subscribed as: [email protected]    Unsubscribe in the 
customer center on our website: 
http://www.bostonworkstation.com/customer_center/virtual_user_group_talk.aspx

________________________________
Portage Health Disclaimer - The information transmitted in this email is 
intended only for the person or entity to which it is addressed and may contain 
confidential and/or privileged material, including protected health 
information. If you are not the intended recipient, you are hereby notified 
that any review, retransmission, dissemination, distribution, or copying of 
this message is strictly prohibited. If you have received this communication in 
error, please destroy and delete this message from any computer and contact us 
immediately by return email.

---  To post a message to this list, send mail to: [email protected]    You are 
currently subscribed as: [email protected]    Unsubscribe in the 
customer center on our website: 
http://www.bostonworkstation.com/customer_center/virtual_user_group_talk.aspx   

Reply via email to