Help...VB

IceT

Senior member
Aug 14, 2000
320
0
0
Is it possible to use the "rnd" function to have VB generates words that make sense? I have been reading the book and it only teaches me on how to randomly pick letters and make words that does not make sense. BTW, I am not asking for direct coding but just wanna know the logical steps toward it...

Another thing, how do I make VB to look into an external file like notepad which will pick up vocabs in it? I mean, like I want VB to pick up a word in the notepad and have it displayed in VB.

Your inputs are greatly appreciated.
 

IceT

Senior member
Aug 14, 2000
320
0
0
OK, I have got an idea. How about asking VB to pick random words out of a dictionary file? How would I do so?
 

KB

Diamond Member
Nov 8, 1999
5,402
386
126
VB has native file reading functions but I don't know them. Instead I use the File System Object. Like this:

'this function opens a file called words.txt and gets a random
'word from the file
Function GetWord()
Dim fso

Set fso=CreateObject("Scripting.FileSystemObject&quot
Dim text, word As string

Set text=fspenTextFile("words.txt&quot

Randomize()

For i=0 to Int(Rnd() * 100)
text.SkipLine
Next
word=Trim(text.Readline)
Set fso=Nothing

GetWord=word
End Function


words.txt would look like this:

hello
computer
stock
offer
etc....
 

IceT

Senior member
Aug 14, 2000
320
0
0
Hey KB, I tried to put your codes in a new form to test but it gave me an error message saying that it needed to have "End Sub". I have put this codes in a "Private Click_Command1()".

Anyway, would u mind explain to me what does the codes do?


----------------------------------------------------------------------------------------


Private Sub Command1_Click()


Function GetWord()
Dim fso

Set fso = CreateObject("Scripting.FileSystemObject&quot
Dim text, word As String
Set text = fspenTextFile("C:\My Documents\words.txt&quot

Randomize ()

For i = 0 To Int(Rnd() * 100)
text.SkipLine
Next
word = Trim(text.Readline)
Set fso = Nothing

GetWord = word
End Function
End Sub

----------------------------------------------------------------------------------------
 

IceT

Senior member
Aug 14, 2000
320
0
0
Also, when I pasted the codes in, Randomize() was highlighted in red.
 

Oli

Member
Jul 20, 2000
98
0
0
Don't put the code in the commnad_click, call it from the command_click.
As for the Randomize function, highlight it and press F1 to have help.

My 2 cents
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |