Micro Focus QTP (UFT) Forums
DP - redescription - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: DP - redescription (/Thread-DP-redescription)



DP - redescription - Kiana - 05-16-2008

Hi, can anyone help me with my script?
I have function and procedure. In both of them I describe the same object, but when I call function in procedure I recive an error.
Here is script:

Code:
Function SectionButtonExist (Section, Button)
Dim oDesc, Sect, oImg

SectionButtonExist = False

    Set oClass=Description.Create()
    oclass("micclass").value="WebTable"
    oclass("innertext").value = ".*" & Section & "   .*"
    Set Sect = Browser(“Browser”).Page(“Page”).childObjects(oClass)

    If Sect.Count>0 Then
        Set Section = Sect(0)
        Set oClass=Description.Create()
        oclass("micclass").value="Image"
        oclass("html tag").value="IMG"
        oclass("alt").value= Button
       Set oImg = Section.childObjects(oClass)

        If oImg.Count >0 Then
            SectionButtonExist = True
            Else
            SectionButtonExist = False
        End If
        
    Else
    SectionButtonExist = False    
    End If

    
End Function


Sub ClickButton (Section, Button)

Dim oDesc, Sect, oImg

Set oClass=Description.Create()
    oclass("micclass").value="WebTable"
    oclass("innertext").value = ".*" & Section & "   .*"
    Set Sect = Browser(“Browser”).Page(“Page”).childObjects(oClass)
    
     If Sect.Count>0 Then
        Set Section = Sect(0)
        Set oClass=Description.Create()
        oclass("micclass").value="Image"
        oclass("html tag").value="IMG"
        oclass("alt").value= Button
       Set oImg = Section.childObjects(oClass)
If SectionButtonExist (Section, Button) Then
            If  oImg.Count >0 Then
            oImg(0).Click
            End If
End If      
  
        End If

  
End Sub



RE: DP - redescription - somisays - 05-16-2008

Hi,
I think you have to declare function as Public.

Regards
Sridhar


RE: DP - redescription - Kiana - 05-23-2008

Thank you. I already find a mistake by myself Rolleyes. I assaigned two object the same name.