VS 2010 : Roadblock With Simple Multiple Choice Form?
Apr 3, 2012
I am trying to create a simple program that delivers True/False questions from a text file and then displays the mark to the student, but I'm running into trouble.I created two forms. The first contains a listbox which is populated with the possible test choices (taken from a .txt file containing only 2 choices). I wrote this code for the listbox
Private Sub frmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Populates listbox with test names from TESTS.txt
Dim sr As IO.StreamReader = IO.File.OpenText("TESTS.txt")
lstTest.Items.Clear()
[code]....
After the test is chosen, the user presses BEGIN. At this point I have my actual Question form pop up, and the first form is hidden. I tried to begin with an If-Then statement which will open the appropriate .txt based on the selection from the first form.
Private Sub frmQuestion_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Opens appropriate test based on selection
If frmTest.txtChosenTest.Text = CStr(frmTest.lstTest.Items(0)) Then
[code]....
This is where I get completely bottle necked though. I've been staring at the screen/textbook for 5 hours now and I don't understand how to write the code that will take my questions from the (now open) text file, separate the question from the answer, and put the question and question number in the appropriate text boxes. The format of the question .txt's are simple. One question per line, with the answer following, separated by a comma. For example, Midterm.txt might look like this
Question1isthisone,T
Question2isthisone,F
If I were to design a form for this problem let's say it would look like this:I am currently stuck at this part though. How do I populate the two read-only text boxes with the question number/question, and then cycle through the questions from the .txt while also keeping the user's score?
View 13 Replies
ADVERTISEMENT
Apr 2, 2011
I'm really new at programming and was looking for guidance about a project I have.I have to design a program that administers a multiple choice test to users. It delivers questions one at a time, from a predefined test file for the user to answer. It also marks and displays a score at the end of the test.
First, a QUESTION form verify's the user's registration status and access. The user provides a registration number and password and the program reads it from a "registration.txt" file to determine if the user is eligible to take the test (i.e., they are registered to take it). If it is correct, then the user presses the "Begin" button. If not, then a message appears and the student tries again to enter the information.
A read only text box will display the score at the end of the test (String with format correct/total) and the user can't retake the test.Second, a QUESTION form opens after clicking "Begin" on the entry form. The questions are going to be from a "testfile.txt" file.Each question is on multiple lines in the file. The first line consists of the question followed by possible answers followed by the correct answer ( 3 items are separated by "#"). The current question number and the question will be displayed in textboxes.'n'= possible answers; so each of the next 'n' lines provides a possible answer. All possible answers will be displayed in a Listbox.After the user selects an answer, an ''Enter'' button is pressed. This will submit and evaluate the answer. If nothing is selected a textbox should appear and display the error message (APPEARS ONLY IF THERE IS AN ERROR). After pressing ''Enter'', the next question is displayed.When all questions answered, the entry form is displayed again and displays the score.
I know that's a lot of information, but I wanted it to be really clear. Would it be best to cycle/loop the questions with a DoWhile loop? And how would I store the answers while the user goes through the test?
View 7 Replies
Feb 24, 2009
I'm not great with VB and I'm having some trouble with my University assignment at the moment.I'm trying to code a multiple choice program with several forms with different questions and then a scoring form
I'm not sure how to tell VB what the correct answer should be and how to display the scores in another form, the answers need to show how many correct in each section out of how many the user attemped to answer, so they can check scores before completing all the questions.
View 5 Replies
May 13, 2012
I'm currently quite new to VB and am trying to create a multiple choice questionnaire for work. This is a depression survey in which there are 23 groups of statements with 4 options per group. Every time a patient clicks an option, the next set of 4 questions comes up on the screen.
I'm trying to convert the old VB4 code into the new VB 2010 code. Before we were using a control array and the code looks a little something like this[code]...
View 2 Replies
May 10, 2009
I need a multiple choice quiz but I've ran into some problems. So far i have 5 arrays: one for the questions and four for the answers. The question is displayed in a label and the answers on radio buttons. Problem one: I am using a random number generator to pull them but this allows them to be reused. How do I stop repeats. Problem two, my grading isn't always working.
View 3 Replies
Nov 3, 2011
I am in the process of creating an array for a set of multiple choice questions but I am having a few problems. I am an absolute beginner at VB and I am creating a quiz that users will select one of three possible questions and then depending on their answer a +1 value will be added to the score. However I do not know where my questions and answers are supposed to go, from what I have read online I have to use (0, 1) format to give possible answers but I do not know how I would make the questions and answers display in textboxes on my form. At the bottom of my code I have also included code to randomise the questions although I am unsure as to if it is correct. At the moment I can run my form fine without any problems but my main issue is to how I will get the questions and answers linked to my textboxes on my form.
Public Class frmTest
Private ran As Random = New Random()
Public intScore As Integer
Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
'Turns the message box invisible when start is clicked
lblMessage.Visible = False
[Code] .....
View 5 Replies
Nov 24, 2009
I am trying to create a form which will be fed by an underlying database to create multiple form fields for each entry in an underlying database table. This is for a program to monitor patients under anesthesia, and prior to surgery, the doctor will choose which monitors they will be using. Then, on the actual monitor screen which will pop up every X minutes, there will be a text box and a check box for each chosen monitor. I am relatively new to VB, so I have tried to illustrate what I am needing but using the logic that I know from my previous life in PHP.
I am using DevExpress's layout control to place the form fields, so that is the code in the middle of the first loop (on_load), and I know that part works, I just need to know how to name the fields and then recover those fields and commit the values to the database. (the text boxes are added to the database, the check boxes are used to determine if an entry is made for that monitor- i.e. at the end of surgery if a monitor is turned off). I know that my syntax for naming the fields is no where close to correct, and it probably would not work in PHP, but I remember doing something like this in a PHP application I built long ago. [Code]
View 3 Replies
Jan 22, 2011
I have to make a multiple choice and true or false quiz in VB. So i am thinking of two questions on one form.BUt i have to make the questions appear in random and not in order and make sure they dont repeat.Btw, i have searched a long time for this. I have found out how to make random numbers. But I have to make sure only 10 come and not repeated.
View 11 Replies
Nov 22, 2011
I am working on a multiple choice quiz, admin screen, student login screen where they choose their level of difficulty. I have been able to start the quiz, have the questions and answers filled, user answers question, check if correct or not, if correct then the score is incremented.I am able to set up a variable for 'level' and want to write some code so that whatever is selected then that table / questions will be selected and displayed to the user.
The way I'm thinking at the moment seems very long winded. I think I'll have to write an IF ELSE statement/case statement for each of the 'navigaterecords' and the sql statment for beginners, intermediate and advanced.Assume there is a variable 'LEVEL' - have not actually done this yet. Where the code refers to 'advanced' is where I have been trying it out to select questions from the advanced table.
Imports System.Data
Imports System.Random
Imports System.Data.OleDb
[code]....
View 8 Replies
Jul 16, 2009
I have a button 'start quiz' which uses the dataset to fill the quiz form - ready for the user to start answering the questions.However, I am getting a 'null reference' at the point where the 'navigate records' on the quiz form is called. Have looked up that it means I have a variable that is null. But I have declared all the variables etc. Not sure what I'm doing wrong. I am very new to programming and I have spent quite a bit of time on this already.This is the code for the student user login:
Private Sub btnLoginStudent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoginStudent.Click
FrmQuiz.Show()
[code].....
View 9 Replies
Mar 12, 2010
I have four drop down lists here and I've assigned the datasource and displaymemberproperties so they are populated by a table. When I run the program and select a choice, all four of them get updated with the new choice.
View 3 Replies
Mar 4, 2011
trying to make a Multiple Choice quiz, with 20 questions
-4 RadioButtons
-2 Label (Reading the Questions) and 1, keeping a score count
Do I wanna make some arrays like Questions(20) and Answers(20)
Dim ScoreCount as Integer
So I want it to be a little screen, and once you click a Radiobutton to choose answer, it will change the label to Question(2) so forth.. but I am unsure how to do this. I am fairly new to vb, im doing this to learn.How do I make it so everytime you click a radiobutton wether it's right or wrong, the next question and possible answers all change??
View 1 Replies
Nov 28, 2009
I am struggling to write code for single-answer multiple choice tests (i.e. Choices A, B, C, D).
View 11 Replies
Feb 1, 2012
on a new project - windows form app i would like to bring a simple stored procedure from a server ( with credentials ) with one parameter.
the stored procedure is on the : "SERVER" "database" "sa" "sa" and it looks like this:
sql
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
[Code]....
also if i could select the client name from a drop down list would be verry nice. the select for the name is : "select name from clients"
The results could be exported into excel or a screen. ( after selecting the client in the form , another button for export )
View 1 Replies
Jan 5, 2012
The following code is a what I have done in order to show a MsgBox when an exit ITEM on a MenuStrip is clicked then it will give two different choices Yes and No. If Yes then it will close the application but if No then it should stay on the same page.
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitMenu.Click
MsgBox("Are you sure you want to exit the program?", MsgBoxStyle.YesNo)
If MsgBoxResult.Yes = True Then
Application.Exit()
End If
View 2 Replies
Nov 22, 2011
I wanted to have one choice enabled to the user(radio box) in two Groupboxes, is that possible? Is looping the why i should do it?
Public Class Form1
Inherits System.Windows.Forms.Form
Dim version As String
[code]....
View 3 Replies
Dec 23, 2011
The problem is when I run/debug my program in Visual Studio 2010, I have a comboBox/dropdown menu which allows the user to select from 3 combinations of years and interest rates. I can select and get output from choices 2 and 3 but not choice 1. Choice 1 being 7 years at 5.35%.
View 3 Replies
Feb 27, 2012
how to create a program that can access information held in an excel database and show it in a simple form.
View 2 Replies
Jul 25, 2011
Is there a better way to make a form with multiple buttons opening different things than having a form that has lots group boxes for each tab. So in the begining each box will be invisible and when you click the button the corresponding group box will become visible. Is there any other way?It will be like a background image and it'll have buttons that will mask it with invisible buttons. when the button is clicked it will open the corresponding group box.
View 5 Replies
Jul 31, 2011
I've got the bulk of a calculator up and working, however it doesn't like multiple operations. For example 3x5+2= brings up 10 (i.e. 3+5+2) and even doing it in two parts doesn't help, if I enter 3x5= I get 15 then +2= gives me 32 (i.e. 3x5=15 15x2=30 30+2=32). Also I am getting trialing zeros in my command line I can't debug.Note that lblcommandline displays the whole function and lbldisplay just displays the current imputted number.
Public Class frmSimpleCalc
'This code is run when the program starts. Here we 'declare' or basically, define which variables we want, what they are and such.
'So, for this example, we need two variables. The number we are CALCULATING and the one which we will CALCULATE FROM.
Dim lCalcNumberMaster As Long 'The master number is the solution, the number stored and displayed when we click equals.
[code]....
View 3 Replies
Oct 1, 2010
How would I go about doing multiple layers on a form?Say the first layer contains a command button that when its click, it changes to the second layer hiding the command button and showing the controls on the second layer?
View 6 Replies
May 22, 2012
I built a form that has 3 Listview objects. Each Listview contains items, the user is to select an item from a Listview and click a button that moves the item "up" or "down" to an adjacent Listview.I am having a difficult time "knowing" which Listview item has been selected. The problem arises once a user has clicked items from different Listviews. Even though, visually, only one item is selected in one Listview, the program still detects a selection from other Listviews.
View 1 Replies
May 26, 2009
VS2008 VB.net. I have a simple Product Class with 20,000 records:
Product(1).partno = "3999399"
Product(1).desc = "Bearing"
Product(1).loc = "34"
This represents ONE sale only and may appear in 100's of other records
Using LINQ how can I: Determine the total count of each partno and then sort by descending order
Example:
Count Partno Desc Loc
3,232 3999399 Bearing Loc 34
2,323 3899388 Bushing Loc 35
etc.
View 5 Replies
Nov 12, 2009
VB.net printing of multiple pages is simple enough utilising the Printdocument. Previewing the pages via the PrintPreviewDialog control is also simple enough.BUT Whereas the doc.print() will cause all pages to be printed stat - the Print button on the PrintPreviewDialog control calls the printPage handler one more time before printing.As all pages have been laid into the document this extra call to the printPage causes only a blank page to be printed. defeat the PrintPreviewDialog call to the handler? - Other than building, previewing and printing each page as a separate job!
[Code]...
View 1 Replies
Apr 22, 2012
I am trying to create a sort of code library in visual basic where the form displays a list box of certain project files in vb that i have made in the past and when clicked, launches the .exe files of those visual basic program project files.I know it does not work the same way as writing/ reading text files to vb and it seems as simple as 'on click, launch .exe of selected string "vb program 1" and so on. I am having trouble getting started on this one. Im sorry I cannot provide any starter code bc I only have a basic understanding of in/out text files which wont work the same way with .exe
View 1 Replies
Jun 9, 2011
I'm making a simple game. I want simultaneously go up and left.
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
' If e.KeyCode = Keys.Z Or e.KeyCode = Keys.Up Then
[CODE]...
Left, right, down and up work. now diagonal.
View 1 Replies
Jun 4, 2012
i am very new to VB and have been trying to make a hangman game. I was wandering if there is a way to add multiple label boxes to a form based on the size of an array. For example a user inputs the word h-e-l-l-o in a input box that word is then split and put into an array(arrword) then i want the main form to appear with 5 label boxes each one containing a letter that from the array(arrword)
View 8 Replies
Apr 22, 2011
Ok so basically heres what i need to do: Extract text from the webpage that meets a certain criteria. There will be a ton of these on 1 page and i would like to add them to a rich textbox on sperate lines.
I know that it needs to be in a loop and its needs to Parse the wepage(Dim web1 As String = Me.WebBrowser1.Document.Body.InnerText)
The criteria is: Starts with 1 to 4(random) integers, Followed by "my" then 13(random) numbers and letters. Or if it starts with "167my" + 6(random) number and letters.
Edit: Also im going to try to make it loop through a list of webpages to do this.
View 5 Replies
Mar 29, 2012
I am having this strange thing happen where I have a Module that contains multiple classes in my project. In the Solution Explorer, the module shows up as a Windows Form and if I double click on it to open it, it tries to open the Form Designer. What could be causing VS to think that it is a Windows Form instead of a module?
[Code]...
View 3 Replies
Aug 7, 2009
Can anyone tell me how to add a Excel like form to a Windows form so I can add and remove rows/colloms and do simple calculation. It would be nice to have tabs along the top.
View 4 Replies