Answered by:
How do you use a word list in VB?

Question
-
Hello
My freind gave me a visual basic word list to use like this :
(//Begin
<level:basic>
Test No.1 <br> type hello:;hello
Test No.2 <br> type how are you:;how are you
//End
<level:advanced>
Test No.3 <br> type this is a test:;this is a test
Test No.4 <br> type you don't know jack:;you don't know jack
Test No.5 <br> type cheating will get you a F on your grade and dismissed:;cheating will get you a F on your grade and dismissed
//End )And its in a WL file he said you can put it into VB and it will read it but i have no idea what he means and cant find anything about it on the web any idea how to use it thanks ??
Fyfe
Thursday, June 30, 2011 9:01 AM
Answers
-
I think you need more information from your friend.
A search for the file extension "wl " at www,wotsit.org turns up nothing. (If someone says "a t x t file", it is taken to mean a file with an extension of ".txt", like readme.txt. If someone says "a WL file", you'd expect then to mean a file with an extension of ".wl".)
The file needs to be parsed in some way to get the data it contains into your program; a WL file does not appear to be some standard which you can expect to be imported natively by VB.
HTH,
Andrew
Thursday, June 30, 2011 8:52 PM -
Hi again Fyfey96,
You could get all the words from a file like this, add the following to a Form to try this code please;
- 1 Button
- 1 RichTextBox
Option Strict On Option Explicit On Option Infer Off Public Class Form1 Dim wordList As New List(Of String) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fileContent As String = "" Using ofd As New OpenFileDialog ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments ofd.Filter = "Text files only|*.txt" Dim result As DialogResult = ofd.ShowDialog If result = Windows.Forms.DialogResult.OK And ofd.FileName <> String.Empty Then fileContent = My.Computer.FileSystem.ReadAllText(ofd.FileName) End If End Using If fileContent <> String.Empty Then Dim fileLines() As String = fileContent.Split(System.Environment.NewLine.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries) Dim splitChars() As Char = (" `1234567890-=[];'#\,./€¬!£$%^&*()_+{}:@~|<>?" & """").ToCharArray wordList = fileContent.Split(splitChars, System.StringSplitOptions.RemoveEmptyEntries).ToList End If RichTextBox1.Lines = wordList.ToArray End Sub End Class
Regards,
John
Click this link to see how to insert a picture into a forum post.
Installing VB6 on Windows 7
XNA is coming to VB.Net
App Hub forums
Thursday, June 30, 2011 2:20 PM
All replies
-
Hi,
It looks a bit like you are wanting to create an "artificial intelligence" program where
you type some words and the computer responds with a meaningful response? YES / NO ?
If YES then you have got a big challenge ahead of you, more often than not the responses from a program may not make sense.
The kind of program I refer to has been written to run on computers with
LOTS of memory and lots of very fast processors, so called SUPER-COMPUTERS.
Some electronics companies have even built human looking robots that respond in an often meaningful manner.
If you just want to add words into a program you can use a LIST, an ARRAY or a DICTIONARY or some other type of collection.
It is quite common to use a LIST(Of String), but what you do with it after that is up to you.>>
Public Class Form1 Dim words As New List(Of String) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load words.Add("aardvark") '....Add more words here. words.Add("zebra") End Sub End Class
Regards,
John
Click this link to see how to insert a picture into a forum post.
Installing VB6 on Windows 7
XNA is coming to VB.Net
App Hub forums
- Edited by John Anthony Oliver Thursday, June 30, 2011 12:41 PM
Thursday, June 30, 2011 12:32 PM -
Yes sorta but my freind says you can put the file into VB and it reads it instead of putting it in manually ??
Thursday, June 30, 2011 12:39 PM -
Yes sorta but my freind says you can put the file into VB and it reads it instead of putting it in manually ??
Hi,
Yes you can get VB to read a file that contains lots of words into memory.
You can even get VB to store all the words that you type as separate words in a file, if you really wanted to do so.
As I said though, building an artificial intelligence program is an entirely different matter.
Regards,
John
Click this link to see how to insert a picture into a forum post.
Installing VB6 on Windows 7
XNA is coming to VB.Net
App Hub forums
Thursday, June 30, 2011 12:44 PM -
Hmm yea how do you do that??
Thursday, June 30, 2011 12:47 PM -
Hmm yea how do you do that??
Hi again,
Which part?
1) Read a file full of words into memory?
2) Store all the words that you type in.
3) Create an automated "artificial intelligence" program?
The program after 1) will not do anything.
As I said part 3) is very difficult to produce any kind of meaningful response for every question that you could type into a computer.
Ask your computer or a brick wall; "What is a brick wall?"
You will get the same kind of response as a computer is just a dumb machine.
I am not going to compare a computers processor to a human brain here as that would be an insult to all humans.
Regards,
John
Click this link to see how to insert a picture into a forum post.
Installing VB6 on Windows 7
XNA is coming to VB.Net
App Hub forums
Thursday, June 30, 2011 1:07 PM -
One way to read the text from a file would be like this:
Dim filePath As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments & "\WordList.txt" Dim lines() As String = IO.File.ReadAllLines(filePath)
This will create an array called lines where each array element is one of the lines from the file WordList.txt in the current user's My Documents folder.Can you explain what you want your application to do with this text? You will probably need a loop to do something with each line, which might look like this:
For Each wordLine As String In lines 'Do something with wordLine Next
Thursday, June 30, 2011 1:14 PM -
Well this is a test application for somthing we want to make similar basicly the Test comes up saying type hello
and then the user types in hello i started to put everything in manually then my freind says you put the WL file in and it reads it?? thats what i dont understand?
Thursday, June 30, 2011 2:19 PM -
Hi again Fyfey96,
You could get all the words from a file like this, add the following to a Form to try this code please;
- 1 Button
- 1 RichTextBox
Option Strict On Option Explicit On Option Infer Off Public Class Form1 Dim wordList As New List(Of String) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim fileContent As String = "" Using ofd As New OpenFileDialog ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments ofd.Filter = "Text files only|*.txt" Dim result As DialogResult = ofd.ShowDialog If result = Windows.Forms.DialogResult.OK And ofd.FileName <> String.Empty Then fileContent = My.Computer.FileSystem.ReadAllText(ofd.FileName) End If End Using If fileContent <> String.Empty Then Dim fileLines() As String = fileContent.Split(System.Environment.NewLine.ToCharArray, System.StringSplitOptions.RemoveEmptyEntries) Dim splitChars() As Char = (" `1234567890-=[];'#\,./€¬!£$%^&*()_+{}:@~|<>?" & """").ToCharArray wordList = fileContent.Split(splitChars, System.StringSplitOptions.RemoveEmptyEntries).ToList End If RichTextBox1.Lines = wordList.ToArray End Sub End Class
Regards,
John
Click this link to see how to insert a picture into a forum post.
Installing VB6 on Windows 7
XNA is coming to VB.Net
App Hub forums
Thursday, June 30, 2011 2:20 PM -
I think you need more information from your friend.
A search for the file extension "wl " at www,wotsit.org turns up nothing. (If someone says "a t x t file", it is taken to mean a file with an extension of ".txt", like readme.txt. If someone says "a WL file", you'd expect then to mean a file with an extension of ".wl".)
The file needs to be parsed in some way to get the data it contains into your program; a WL file does not appear to be some standard which you can expect to be imported natively by VB.
HTH,
Andrew
Thursday, June 30, 2011 8:52 PM -
Well this is a test application for somthing we want to make similar basicly the Test comes up saying type hello
Do you mean that you want text-to-speech?
Thursday, June 30, 2011 9:16 PM -
I don't want text to speech and it was a WL file i am as confused as you guys :(Friday, July 1, 2011 8:35 AM
-
Hi Fyfey,
Welcome to the MSDN Forum.
I agree with Andrew, You should ask your friend for more detail information, how does the VB program can auto-read it, has the program been developed or is going to develop it?
We need the more details as the same as you.
Best regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Monday, July 4, 2011 4:58 AM