vb.net "Name is not declared" question

G

Guest

Hi,
I'm new to vb.net programming, and I keep getting this error: Name
'GetQuery' is not declared. I can't figure out why?? It seems like I have
the right references/namespaces. This is my code below. Also, can someone
explain to me what the ContentHandlerImpl.vb file actually does? It's in
this project that I'm working with...but I'm not sure what the file actually
does. Thanks!!

Imports System.Xml
Imports Lucene.Net.Documents
Imports Lucene.Net.Analysis
Imports Lucene.Net.Index

Imports Lucene.Net.Search
Imports Lucene.Net.QueryParsers
Imports Lucene.Net.Util
Imports System
Imports System.IO

Public Class SampleSearch2
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents txtGender As System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtConsent As System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtIMBDystResult As
System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtIMFDystResult As
System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtIMBDystDiag As
System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtIMFDystDiag As
System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtIMFMerosinResult As
System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents SearchButton As System.Web.UI.WebControls.Button
Protected WithEvents lblText As System.Web.UI.WebControls.Label
Protected WithEvents lblResults As System.Web.UI.WebControls.Label
Protected WithEvents txtFetus As System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents SearchButton1 As System.Web.UI.WebControls.Button
Protected WithEvents txtDescription As System.Web.UI.WebControls.TextBox
Protected WithEvents txtIMBDysferlin As
System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtIMFAlpha As System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtIMFMerosin As
System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtAgeFrom As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAgeTo As System.Web.UI.WebControls.TextBox
Protected WithEvents txtDateTo As System.Web.UI.WebControls.TextBox
Protected WithEvents txtDateFrom As System.Web.UI.WebControls.TextBox
Protected WithEvents txtAsymp As System.Web.UI.HtmlControls.HtmlSelect
Protected WithEvents txtFamilyHistory As
System.Web.UI.HtmlControls.HtmlSelect

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private strXmlFilePath As String = Server.MapPath("/xmlsearch/xmlfiles/")
Private strIndexFilePath As String =
Server.MapPath("/xmlsearch/xmlindex/")
Private searcher As IndexSearcher = New IndexSearcher(strIndexFilePath)
Private analyzer As Standard.StandardAnalyzer = New
Standard.StandardAnalyzer

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub


Private Sub SearchButton1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles SearchButton1.Click
Dim strGender As String
Dim strConsent As String
Dim strFetus As String
Dim strAgeFrom As String
Dim strAgeTo As String
Dim strAge As String
Dim strDateFrom As String
Dim strDateTo As String
Dim strDate As String
Dim strAsymp As String
Dim strFamilyHistory As String
'IMF for Immuno-flourescence
Dim strIMFDystResult As String
Dim strIMFDystDiag As String
Dim strIMFMerosin As String
Dim strIMFAlpha As String
'IMB for Immunoblot
Dim strIMBDystResult As String
Dim strIMBDystDiag As String
Dim strIMBDysferlin As String
Dim strDesc As String


Dim searcher As IndexSearcher = New IndexSearcher(strIndexFilePath)
Dim analyzer As Standard.StandardAnalyzer = New
Standard.StandardAnalyzer
Dim hits As Hits

'start with every click, we need to clean the result
lblText.Text = ""
lblResults.Text = ""
strAge = ""
strDate = ""

strGender = txtGender.Value.ToUpper
strConsent = txtConsent.Value.ToUpper
strFetus = txtFetus.Value.ToUpper
strAgeFrom = txtAgeFrom.Text
strAgeTo = txtAgeTo.Text
strDateFrom = txtDateFrom.Text
strDateTo = txtDateTo.Text
strAsymp = txtAsymp.Value.ToUpper
strFamilyHistory = txtFamilyHistory.Value.ToUpper
strIMFDystResult = txtIMFDystResult.Value.ToUpper
strIMFDystDiag = txtIMFDystDiag.Value.ToUpper
strIMFMerosin = txtIMFMerosin.Value.ToUpper
strIMFAlpha = txtIMFAlpha.Value.ToUpper
strIMBDystResult = txtIMBDystResult.Value.ToUpper
strIMBDystDiag = txtIMBDystDiag.Value.ToUpper
strIMBDysferlin = txtIMBDysferlin.Value.ToUpper

strAgeFrom.Trim()
If strAgeFrom.Length = 1 Then
strAgeFrom = "00" & strAgeFrom
ElseIf strAgeFrom.Length = 2 Then
strAgeFrom = "0" & strAgeFrom
ElseIf strAgeFrom.Length = 0 Then
strAgeFrom = "000" 'minimun age
End If

strAgeTo.Trim()
If strAgeTo.Length = 1 Then
strAgeTo = "00" & strAgeTo
ElseIf strAgeTo.Length = 2 Then
strAgeTo = "0" & strAgeTo
ElseIf strAgeTo.Length = 0 Then
strAgeTo = "120" 'maximun age
End If


'we will use wildcard for strDesc
strDesc = txtDescription.Text
Dim strWords() As String = strDesc.Split(" ")

'Construct the query based upon the input
If strGender.Length > 0 Then
strGender = "+GENDER:" & strGender
End If

If strConsent.Length > 0 Then
strConsent = "+IS_CONSENT_FORM:" & strConsent
End If

If strFetus.Length > 0 Then
strFetus = "+IS_FETUS:" & strFetus
End If

' the logic here is both length of strAgeFrom and strAgeTo are
greather than 0
' but if strAgeFrom = "000" and strAgeTo = "120" that means neither
one is entered by users
If strAgeFrom.Equals("000") And strAgeTo.Equals("120") Then
Else
strAge = "+AGE_YEAR:[" + strAgeFrom + " TO " + strAgeTo + "]" &
strAge
End If

'must contain both DateFrom and DateTo to search. Use AND instead of
OR
If strDateFrom.Length > 0 And strDateTo.Length > 0 Then
strDate = "+BIOPSY_DATE:[" + strDateFrom + " TO " + strDateTo +
"]" & strDate
End If

If strFamilyHistory.Length > 0 Then
strFamilyHistory = "+FAMILY_HISTORY:" & strFamilyHistory
End If

If strIMBDystResult.Length > 0 Then
strIMBDystResult = "+DYST_RESULT:" & strIMBDystResult
End If

If strIMBDystDiag.Length > 0 Then
strIMBDystDiag = "+DYST_DIAGNOSIS:" & strIMBDystDiag
End If

If strIMBDysferlin.Length > 0 Then
strIMBDysferlin = "+DYSFERLINE_RESULT:" & strIMBDysferlin
End If

If strIMFDystResult.Length > 0 Then
strIMFDystResult = "+DYST_RESULT_FLO:" & strIMFDystResult
End If

If strIMFDystDiag.Length > 0 Then
strIMFDystDiag = "+DYST_DIAGNOSIS_FLO:" & strIMFDystDiag
End If

If strIMFMerosin.Length > 0 Then
strIMFMerosin = "+MEROSIN_RESULT_FLO:" & strIMFMerosin
End If

If strIMFAlpha.Length > 0 Then
strIMFAlpha = "+ALPHA_SAC_RESULT_FLO:" & strIMFAlpha
End If


If strDesc.Length > 0 Then
'the description field is wild card searc
'clean up the strDesc first
strDesc = ""
Dim i As Integer
For i = 0 To strWords.Length - 1
Dim strWord As String = strWords(i)
strWord.Trim()
If strWord.Length > 0 Then
'append the "*"
strWord = strWord + "*"
End If
strDesc += "+" + strWord + " "
Next
strDesc = "+OTHER:(" + strDesc + ")"
Else
'clean up the strDesc
strDesc = ""
End If

'concatenate the query
Dim strQuery As String = ""

If strGender.Length > 0 Then
strQuery += strGender + " "
End If

If strFetus.Length > 0 Then
strQuery += strFetus + " "
End If

If strAge.Length > 0 Then
strQuery += strAge + " "
End If

If strDate.Length > 0 Then
strQuery += strDate + " "
End If

If strConsent.Length > 0 Then
strQuery += strConsent + " "
End If

If strFamilyHistory.Length > 0 Then
strQuery += strFamilyHistory + " "
End If

If strIMBDystResult.Length > 0 Then
strQuery += strIMBDystResult + " "
End If

If strIMBDystDiag.Length > 0 Then
strQuery += strIMBDystDiag + " "
End If

If strIMBDysferlin.Length > 0 Then
strQuery += strIMBDysferlin + " "
End If

If strIMFDystResult.Length > 0 Then
strQuery += strIMFDystResult + " "
End If

If strIMFDystDiag.Length > 0 Then
strQuery += strIMFDystDiag + " "
End If

If strIMFMerosin.Length > 0 Then
strQuery += strIMFMerosin + " "
End If

If strIMFAlpha.Length > 0 Then
strQuery += strIMFAlpha + " "
End If

If strDesc.Length > 0 Then
strQuery += strDesc
End If

Dim query1 As Query = GetQuery(strQuery, analyzer)

'Search
Try
hits = searcher.Search(query1)
Catch myerr As SystemException
lblText.Text = "There are no documents that match your search."
Exit Sub
Finally

lblText.Text = "Found " & hits.Length() & " record(s) that
matched query<br> "
' "Gender: <b>" & txtGender.Value & "</b><br> " & _
' "Fetal muscle: <b>" & txtFetus.Value &
"</b><br> " & _
' "Consent form: <b>" & txtConsent.Value &
"</b><br> " & _
' "Immunoblot dystrophin result: <b>" &
txtIMBDystResult.Value & "</b><br> " & _
' "Immunoblot dystrophin diagnosis: <b>" &
txtIMBDystDiag.Value & "</b><br> " & _
' "Immuno-flourescence dystrophin result:<b>" &
txtIMFDystResult.Value & "</b><br> " & _
' "Immuno-flourescence dystrophin diagnosis:<b>" &
txtIMFDystDiag.Value & "</b><br> " & _
' "Comments<b>" & txtDescription.Text & "</b><br>"
Dim i As Integer = 0
For i = 0 To hits.Length - 1
Dim doc As Document = hits.Doc(i)
lblResults.Text &= "<li>PROCEDURE ID: " &
doc.Get("PROCEDURE_ID").TrimEnd & _
" SUBJECT ID: " & doc.Get("SUBJECT_ID").TrimEnd & _
" <a href='searchsubject.aspx?subject_ID=" &
doc.Get("SUBJECT_ID").Trim & _
"' target='_blank'>Choose this record</a></li>"
' "<a href='target.aspx?target=view&subject_ID=" &
doc.Get("SUBJECT_ID").Trim & _
'"&proc=" & doc.Get("PROCEDURE_ID").Trim & _
'"&biopsy=" & doc.Get("BIOPSY_ID").Trim & _
'"&age=" & doc.Get("AGE_YEAR").Trim & _
'"&physician=" & doc.Get("PHYSICIAN_ID").Trim & _
'"&fetus=" & doc.Get("IS_FETUS").Trim & _

Next
lblResults.Text &= "</ul>"
End Try

End Sub


End Class
 
J

Jon Skeet [C# MVP]

ST said:
I'm new to vb.net programming, and I keep getting this error: Name
'GetQuery' is not declared. I can't figure out why?? It seems like I have
the right references/namespaces. This is my code below. Also, can someone
explain to me what the ContentHandlerImpl.vb file actually does? It's in
this project that I'm working with...but I'm not sure what the file actually
does. Thanks!!

Well, what GetQuery are you trying to call? You've shown the attempt to
call it, but no declaration for it.
 
G

Guest

What do you mean exactly? Sorry, this is code that somebody else did, and
they told me to just add it into an existing project we have.
 
J

Jon Skeet [C# MVP]

ST said:
What do you mean exactly? Sorry, this is code that somebody else did, and
they told me to just add it into an existing project we have.

Then you need to ask them for the GetQuery method as well - and then
start learning VB.NET from scratch, rather than from existing code. I
know it's harsh, but learning from first principles is much more likely
to get you a good firm foundation in the language (and the framework).
 
G

Guest

The getquery method seems to be under Lucene.net.search when I look in the
object browser. (Lucene.net.search.topdocs>weight..and when I highlight
weight, I see it on the right).

So it seems like it's there...so I don't know why the error is coming up?

As far as learning vb.net from scratch...I WISH that was an option for me
right now, but unfortunately it's not and I'm forced to learn it on my own in
as little time as possible for my job :( but I'm trying!!! The more
questions I ask, the more I seem to figure out...
 
G

Guest

Do you have any suggestions for good books to help me with this? I have the
Microsoft Press Visual Basic.NET step by step...but I'm only working with web
applications, not windows, and it only has a little section in there on web
apps...and it's not very detailed.
 
G

Guest

I actually figured out that issue by including this file (LuceneUtils.vb)
into the project. It has this code:
Imports System.Xml
Imports Lucene.Net.Documents
Imports Lucene.Net.Analysis
Imports Lucene.Net.Index

Imports Lucene.Net.Search
Imports Lucene.Net.QueryParsers
Imports Lucene.Net.Util
Imports System
Imports System.IO

Module LuceneUtils
Public Function getParser(ByRef a As Analyzer) As QueryParser
If (a Is Nothing) Then
a = New SimpleAnalyzer
End If
Dim qp As QueryParser = New QueryParser("body", a)
qp.SetOperator(QueryParser.DEFAULT_OPERATOR_OR)
Return qp
End Function

Public Function getQuery(ByVal query As String, ByRef a As Analyzer) As
Query
Return getParser(a).Parse(query)
End Function
End Module

But NOW....when I try and debug, I'm getting this error:

Parser Error
Description: An error occurred during the parsing of a resource required to
service this request. Please review the following specific parse error
details and modify your source file appropriately.

Parser Error Message: Could not load type 'biopsy._default'.

Source Error:


Line 1: <%@ Register TagPrefix="uc1" TagName="menu" Src="menu.ascx" %><%@
Page Language="vb" AutoEventWireup="false" Codebehind="default.aspx.vb"
Inherits="biopsy._default"%>
Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
Line 3: <HTML>


Source File: c:\inetpub\wwwroot\biopsy\default.aspx Line: 1


Any ideas why this is happening? If you have time, can you explain to me
what exactly that Luceneutil file is for, and why it's affecting the rest of
my files now? Thanks!!
 
J

Jon Skeet [C# MVP]

Any ideas why this is happening? If you have time, can you explain to me
what exactly that Luceneutil file is for, and why it's affecting the rest of
my files now? Thanks!!

I haven't used Lucene for .NET - but I suggest you read their
documentation, and/or ask the colleague who passed the task on to you.
 
J

Jon Skeet [C# MVP]

ST said:
The getquery method seems to be under Lucene.net.search when I look in the
object browser. (Lucene.net.search.topdocs>weight..and when I highlight
weight, I see it on the right).

So it seems like it's there...so I don't know why the error is coming up?

As far as learning vb.net from scratch...I WISH that was an option for me
right now, but unfortunately it's not and I'm forced to learn it on my own in
as little time as possible for my job :( but I'm trying!!! The more
questions I ask, the more I seem to figure out...

But by learning it from scratch, you'll save yourself time in the long
run even within your job. If you learn properly, you'll have far fewer
questions - you may find it takes longer to get to your 10th line of
code, but by the 1000th you'll be saving time.
 
J

Jon Skeet [C# MVP]

ST said:
Do you have any suggestions for good books to help me with this? I have the
Microsoft Press Visual Basic.NET step by step...but I'm only working with web
applications, not windows, and it only has a little section in there on web
apps...and it's not very detailed.

That doesn't matter at all. You should be learning the *language*
first, then the very *core* classes (IO and collections spring to
mind). After that, learning ASP.NET or Windows Forms is just a layer
which uses the rest.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top