Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if condition throwing type mismatch error
#1
Not Solved
Hi,

I am gettingtype mismatch errror when I run the following code's if condition. can some one tell me what is wrong in my code.
Attached error image.

And one more thing I have another attribute primary="true" which is optional and may not show up for all the image nodes also have to be in if condition. How to code that



Code:
Set urinode=xmlDoc.SelectSingleNode(imgcat)



                imgcategory= urinode.getAttribute("category")

                imgwidth=urinode.getAttribute("width")

                imgheight=urinode.getAttribute("height")



                nodepath1 = "/on/programs/program[" & i& "]/images/image[" & j & "]/URI/text()"

                Set node = xmlDoc.SelectSingleNode(nodepath1)



If ((imgcategory="Poster Art")&(imgwidth="72")&(imgheight="108")) then

                xlSheet.Rows(nRow).Columns(iCol).value=TMS

                xlSheet.Rows(nRow).Columns(iCol+1).value=node.NodeValue

                xlSheet.Rows(nRow).Columns(iCol+2).value=imgcategory

                xlSheet.Rows(nRow).Columns(iCol+3).value=Yes

else

                xlSheet.Rows(nRow).Columns(iCol).value=TMS

                xlSheet.Rows(nRow).Columns(iCol+1).value=node.NodeValue

                xlSheet.Rows(nRow).Columns(iCol+2).value=imgcategory

                End If


Attached Files
.doc   typemismatch.doc (Size: 31 KB / Downloads: 63)
Reply
#2
Not Solved
Hi,

Instead of "&", use "AND". Actually in VB, "&" operator is used to concatenate 2 Strings.

Now your code should look like

Code:
If ((imgcategory="Poster Art") AND (imgwidth="72") AND (imgheight="108")) then

The code below doesn't provide enough information about what you want to do or how you want to include it in the IF condition. Please provide a good description

Quote:And one more thing I have another attribute primary="true" which is optional and may not show up for all the image nodes also have to be in if condition. How to code that
Reply
#3
Not Solved
Thanks Prabath AND works.
And for the one you asked clarification:
I have a node image which may or may not have attribute primay.When ever it is available I want to add a column in excel that it exists.
This is the xml node without primary attribute
Code:
<image type="image/jpg" width="432" height="288" category="Poster Art">
<URI>AllPhotos/26454/26454_ac.jpg</URI>
<caption>Poster Art</caption>
<provider>Unspecified</provider>
</image>
This is the xml node with primary attribute

Code:
<image type="image/jpg" width="288" height="432" primary="true" category="Poster Art">
<URI>AllPhotos/26454/26454_aa.jpg</URI>
<caption>Poster Art</caption>
<provider>Unspecified</provider>
</image>

And the code I wrote was
Code:
If ((imgcategory="Poster Art")AND(imgwidth="72")AND(imgheight="108")) then
If urinode.Attribute("primary")<>0 Then
xlSheet.Rows(nRow).Columns(iCol).value=TMS
xlSheet.Rows(nRow).Columns(iCol+1).value=node.NodeValue
xlSheet.Rows(nRow).Columns(iCol+2).value=imgcategory
xlSheet.Rows(nRow).Columns(iCol+3).value="Yes"
imgprimary=urinode.getAttribute("primary")
xlSheet.Rows(nRow).Columns(iCol+4).value=imgPrimary
else
xlSheet.Rows(nRow).Columns(iCol).value=TMS
xlSheet.Rows(nRow).Columns(iCol+1).value=node.NodeValue
xlSheet.Rows(nRow).Columns(iCol+2).value=imgcategory
xlSheet.Rows(nRow).Columns(iCol+3).value="Yes"
End If
   else
xlSheet.Rows(nRow).Columns(iCol).value=TMS
xlSheet.Rows(nRow).Columns(iCol+1).value=node.NodeValue
xlSheet.Rows(nRow).Columns(iCol+2).value=imgcategory
End If
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Different Type of Dropdown Selector zunebuggy 6 2,832 05-01-2018, 06:46 PM
Last Post: zunebuggy
  Need to verify the drop down values based on condition santhoshmscsoftware 1 2,710 05-04-2016, 11:28 PM
Last Post: supputuri
  cannot use the type method on object and submit is not working jove1776 5 8,379 01-27-2015, 10:08 PM
Last Post: Parke
  How to import .xlsx file type to QTP qtped 3 6,313 03-27-2014, 01:33 PM
Last Post: Ankur
  type mismatch error in QTP QAlearningQTP 1 6,803 02-04-2014, 08:14 AM
Last Post: QAlearningQTP

Forum Jump:


Users browsing this thread: 1 Guest(s)