percentage calculation - name not declared

liunx

Guest
hi.

I am rather new to the whole .net thing lol so be gental and explain well as im thick lol.

right well i am trying to do a match against words based on a users input and then based against the xml questions. (Type of knowledgebase)

I compare the words and add 1 to a counter / qcounter if they are found.

counter and qcounter are set as an integer and in there first use counter = counter +1 it works but when i go to do the following it says that qcounter is not declared which is confusing me is it because i set it to an integer?

Here is my code so you can see what i have been up to.

It is missing a way of ending the loop if it finds the words (only want it to find each word once unless this is a bad idea all idea welcome.)

Then some comments on search idea would be good like searching for the words in exact order. Number of times each word appears etc.

<%@ Page Language="VB" ContentType="text/html" Debug="true"%>
<html>
<head>
<title>Knowledge Base Design</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%@ Import Namespace="System.XML"%>
<%@ Import Namespace="System.IO"%>

<script language="VB" Runat="server">
Dim StrOut

Sub submit(sender As Object, e As EventArgs)
'This sub class will take the users entered question after the submit button has been pressed and split it
'into seperate words.
Dim textdelimiter as String'Declare the variable to a string
dim aQuestion as String'Declare the variable to a String
dim i as integer'Declare the variable i as a integer

'Split the usersquestion into single words
aQuestion = UserQuestion.Text'assign the question asked by the user to aquestion
Textdelimiter = ??'Make the Textdelimiter look for spaces
Dim wordout = Split(aQuestion,textdelimiter)'Split the aQuestion into seperate words and assign it to splitout

'loop through the array of wordout until it reaches the end.
'for i=0 to Ubound(wordout)
'lbl1.Text &= "<b>Question </b>" & i+1 & ") " & wordout(i)& "<br>"'print out as such split(i) splitout(i)
'Next
Call KnowledgeBase(wordout)
end sub

Sub page_load(sender as object, e as EventArgs)
'Call Display_News()
End Sub

Sub KnowledgeBase(wordout)
Dim Xread as XMLTextReader = new XMLTextReader(Server.MapPath("knowledgebase.xml"))
try
While xread.Read()
Select Case xread.NodeType
Case XMLNodeType.Element
dim questionin as String
if xread.Name = "Question" then
questionin = xread.ReadString()
Dim textdelimiter as String'Declare the variable to a string
dim aQuestion as String'Declare the variable to a String
dim i as integer'Declare the variable i as a integer
dim j as integer'Declare the variable i as a integer
dim counter as integer'Declare the variable i as a integer
dim qcounter as integer'Declare the variable i as a integer
'Split the usersquestion into single words
Textdelimiter = ??'Make the Textdelimiter look for spaces
Dim questionOut = Split(questionin,textdelimiter)'Split the aQuestion into seperate words and assign it to splitout

'loop through the array of splitout until it reaches the end.
for i=0 to Ubound(wordout)
qcounter = qcounter + 1
for j=0 to Ubound(QuestionOut)
if StrComp(wordout(i),questionOut(j),1)=0 then
counter = counter + 1
end if
next
next
'lbl1.Text &="<b>Match </b> )<a href=http://www.webdeveloper.com/forum/archive/index.php/""http://www.rgu.ac.uk"">" & questionin & "</a> <br>"
End If
dim percentageMatch = (qcounter / counter *100)'Work out the percentage hit for each knowledge base entry.
if percentageMatch > 50 then ' This will be used to work out what percentage of words matched.
lbl1.Text &="<b>Match </b> )<a href=http://www.webdeveloper.com/forum/archive/index.php/"""">" & questionin & "</a> <br>"
end if
End Select
End While
Catch ex as Exception
Response.Write("Error Happened")
Finally
xread.close()
End try
lblXML.Text = strOut
End Sub


</script>
<asp:label id="lblXML" runat="server" />

<form runat="server">
Your Question: <asp:TextBox id="UserQuestion" runat="server" />
<asp:Button OnClick="submit" Text="Submit" runat="server" />
<p><asp:Label id="lbl1" runat="server" /></p>
</form>
<a href=http://www.webdeveloper.com/forum/archive/index.php/"http://www.rgu.ac.uk"></a>
</body>
</html>


Thanks for any helpcan anyone help plzis there anyone that help as i am really stuck in why it all of a sudden no longer has them registeredTry out this forum (<!-- m --><a class="postlink" href="http://forums.asp.net">http://forums.asp.net</a><!-- m -->), coz i guess no one understands what is you want.
 
Top