BC30203: Identifier expected in a n if statement

Posted on 2014-01-31
Medium Priority
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

Open in new window

Question by:runnerjp2005
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
LVL 23

Expert Comment

by:Ioannis Paraskevopoulos
ID: 39823617

Use the following instead:

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

Open in new window


Author Comment

ID: 39823625
Hi Giannis,

I now get the error

System.NullReferenceException: Object variable or With block variable not set.
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.

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

LVL 23

Expert Comment

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

Author Comment

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
LVL 23

Accepted Solution

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

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

Open in new window


Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 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