Solved

BC30203: Identifier expected in a n if statement

Posted on 2014-01-31
6
273 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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 …
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

12 Experts available now in Live!

Get 1:1 Help Now