Accessing Random External Txt Files
Accessing Random External Txt Files
Accessing Random External Txt Files
Accessing Random External Txt Files
Accessing Random External Txt Files
Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files
Accessing Random External Txt Files Accessing Random External Txt Files
Accessing Random External Txt Files
Go Back  Xtreme Visual Basic Talk > > > Accessing Random External Txt Files


Reply
 
Thread Tools Display Modes
  #1  
Old 10-30-2007, 11:37 AM
mr_pwnage mr_pwnage is offline
Newcomer
 
Join Date: Oct 2007
Posts: 8
Unhappy Accessing Random External Txt Files


OK, so I have to make a program for my school programming unit. It has to be completely my program and my idea. But I can't figure one thing out...

I am making a maths challenge program which quizzes on someones maths and gives them a score when they are done.

So, here I go.

I have made several text files which hold questions and answers.
eg.

easyQ1
What is 1+1?
2

So the question is line 1 and the answer is line 2. There are many of these with medium and hard.

I have 3 modes to the program; easy, normal and hard mode. This is selected by a dropdown box.

All I need to do is figure out exactly how to make the program open up a random file and line1=question which goes in an inputbox which pops up. and answer, which they must match in the field in the inputbox.

Here is what I have so far; (VB 2005 Express Edition)
Megaupload link
Reply With Quote
  #2  
Old 10-31-2007, 04:59 PM
mr_pwnage mr_pwnage is offline
Newcomer
 
Join Date: Oct 2007
Posts: 8
Talking

Nevermind. I used a different thing.

Code:
        Dim No1 As Integer
        Dim No2 As Integer

        No1 = System.DateTime.Now.Millisecond
        No2 = System.DateTime.Now.Second

        Answer = InputBox("What is " & No1 & " plus " & No2 & "?", "Question 1")
        If Answer = No1 + No2 Then
            Correct = True
        Else
            Correct = False
        End If
So that works well enough.
Reply With Quote
  #3  
Old 11-01-2007, 06:09 PM
Iceplug's Avatar
IceplugAccessing Random External Txt Files Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

You can also use the Random class to create random integers.
at startup, make a new one
Dim Ri As Random
Ri = New Random


No1 = Ri.Next(50)
No2 = Ri.Next(50)
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #4  
Old 11-04-2007, 04:53 PM
mr_pwnage mr_pwnage is offline
Newcomer
 
Join Date: Oct 2007
Posts: 8
Default

so I take it 50 is the maximum number this random can be?
Reply With Quote
  #5  
Old 11-04-2007, 05:09 PM
user name user name is offline
Junior Contributor
 
Join Date: Sep 2004
Posts: 264
Default

No, the random number returned is always less than the maximum value entered but if you supply a minimum value aswell, the minimum value would be what you entered.
Code:
Ri.Next(50)   ' this returns 0 to 49

Ri.Next(4, 50)  ' this returns 4 to 49
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Accessing Random External Txt Files
Accessing Random External Txt Files
Accessing Random External Txt Files Accessing Random External Txt Files
Accessing Random External Txt Files
Accessing Random External Txt Files
Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files Accessing Random External Txt Files
Accessing Random External Txt Files
Accessing Random External Txt Files
 
Accessing Random External Txt Files
Accessing Random External Txt Files
 
-->