Solved

BC30203: Identifier expected in a n if statement

Posted on 2014-01-31
6
276 Views
Last Modified: 2014-01-31
I am getting the error "BC30203: Identifier expected." on this line if Div.selectSingleNode("./td[@class='score']").InnerText != null then and i can't figure out why...


		For Each div As Object In htmlDoc.DocumentNode.SelectNodes("//div[@class='matches']")' select all the divs within the code that contain *
 
    if Div.selectSingleNode("./td[@class='score']").InnerText != null then
		  lblHTMLOutput.Text += Div.selectSingleNode("./td[@class='score']").InnerText
    end if
        Next

Open in new window

0
Comment
Question by:runnerjp2005
  • 4
  • 2
6 Comments
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 39823617
Hi,

Use the following instead:

if Div.selectSingleNode("./td[@class='score']").InnerText <> nothing then

Open in new window


Giannis
0
 

Author Comment

by:runnerjp2005
ID: 39823625
Hi Giannis,


I now get the error

System.NullReferenceException: Object variable or With block variable not set.
0
 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 39823628
Hmmm... Try the following:

if not Div.selectSingleNode("./td[@class='score']") is nothing then

Open in new window


if that doesn't work, plz provide a sample html where you get the error(if it is different than your other question), and possibly provide more of your code.

Giannis
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 39823632
I have updated my previous post.
0
 

Author Comment

by:runnerjp2005
ID: 39823635
Operator '<>' is not defined for type 'HtmlNode' and 'Nothing'. is the error i get now....

full code is

Imports System.Net 
Imports System.IO 
Imports HtmlAgilityPack

Partial Class football_home
    Inherits System.Web.UI.Page

		Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
			
Dim webGet As New HtmlWeb() 'open the system
        Dim htmlDoc As HtmlDocument = webGet.Load("http://www.livefutbol24.com/Football/Live")'' get the html from the webpage

      

		For Each div As Object In htmlDoc.DocumentNode.SelectNodes(".//div[@class='matches']")' select all the divs within the code that contain *
 
   if Div.selectSingleNode(".//td[@class='score']") <> nothing then
		  lblHTMLOutput.Text += Div.selectSingleNode(".//td[@class='score']").InnerText
		  end if
 
        Next  End Sub
	
End Class

Open in new window


its different from other question as im looking to deal with null values
0
 
LVL 23

Accepted Solution

by:
Ioannis Paraskevopoulos earned 500 total points
ID: 39823639
Check my updated post:

If Not Div.selectSingleNode(".//td[@class='score']") Is Nothing Then

Open in new window


Giannis
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now