Vb2008 - Randomizing - Addition Exercise Or A Subtraction Exercise ?
Jul 2, 2011I have (label1.text), a combobox(items = + , -), (label2.text) = answer1.text
What I want to do is randomize if its an addition exercise or a subtraction exercise.
I have (label1.text), a combobox(items = + , -), (label2.text) = answer1.text
What I want to do is randomize if its an addition exercise or a subtraction exercise.
This exercise says :"Write a program that inputs one number consisting of five digits from the user, separates the number into its individual digits and prints the digits separated from one another by three spaces each. For example, if the user types the number 42339, the program should print
4 2 3 3 9 Use the command window for input and output. [Hint: This exercise is possible with the techniques discussed in this chapter. You will need to use both division and modulous operations go "pick off" each digit.]"
Here is what I have learned in Chapter 3:
�If/Then Statements
�Console.Write()
�Console.WriteLine()
[Code]....
This exercise I have yet to start, and don't think I will be able to do much, because I have no clue how to "Pick off" the numbers using division and modulous operators. I know what the mod operator does, but I do not know how to use it and division to do what this exercise is asking me to do.
Write a program to calculate the average of three exam marks. The input and output should be done by subprograms GetMarks and DisplayAverage respectively. the calculation should be done by a function, CalcAverage. This is my code:
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim student As String, exam1 As Integer, exam2 As Integer, exam3 As Integer
Dim average As Double
lstResult.Items.Clear()
[code]....
How do you make the tab key invoke command such as in Exercise 40 ,Page 51?
View 2 RepliesA parking garage charges a $2 min. fee to park for up to three hours.The garage charges an additional 50 cent per hour for each hour or part thereof in excess of three hours. The max charge for any given 24-hour period is $10. Assume that no car parks for longer than 24 hours at a time. Write a program that calculates and displays the parking charges for each customer who parkes a car in this garage yesterday. You should enter in a TextBox the hours parked for each customer. The program should display the charge for the current customer. THe program should ise the method CalculateCharges to determine the charge for each customer. Ise the techniques described in the chapter to read Double value fro a TextBox. [ You may need to use methods Convert.ToDouble and Convert.ToDecimal when doing calculations with the number of hours and charges]
Public Class ParkingGarageFeeCalculatorForm
Private Sub calculateButton_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles calculateButton.Click
Dim hoursParked As Double = Convert.ToDouble(hoursParkedTextBox.Text)
[code].....
I've been working for several days on a GUI where a lot of individual data elements need to be displayed side-by-side and wrap to the next line when they overflow; the goal is to not have to explicitly design an individual 'row' element with a set number of elements for this purpose. The FlowLayoutPanel seems great, except...
I need to be able to determine how many elements are on each line (dividing the width of the control by a predetermined value indicating width of child controls does not work); I need to be able to determine how many elements will be on each line (I may need to put 4 elements on line 1, then auto-wrap, then 8 elements on line 2, then auto-wrap, then as many elements as can fit on line 3 before autowrap, then 16 elements on line 4, etc); and finally I'd really like to put a 'line header' at the left margin and a 'line footer' at the right margin, where for example the line header contains a line number and the line footer contains the number of elements on that line.
I have a form that has 10 addition execises. The user has the option of using a timer or not. I have the timer part correct, but now I want to be able to check the exercise answer one by one as the user inputs the info.
[Code]...
I have a form with 10 math questions. Beside each question there will appear a check mark if it is right and a X if its wrong. I also have a label that will display a score in percentage. If 2 are right then it will display 20%. If they are all right then it displays 100%. My problem is ...how can I code the event. I thought of case select, but that would mean 100 cases to make it work.( If check1 and check2 are visible then display 20%, but if its check1 and check 7? Thats alot) What I want ot know if there is an easier or shoter way to ontain the same result. I am working with Visual Basic 2008.
View 7 Repliesi am currently making a maths game but i have run in to trouble trying to do the addition and subtraction side of the game. This is my current class file for my multiplication
Public Class Class2
Private Property question_gameplay_label As String
Private Property correctAnswer As Integer
[code]....
I got a problem with my calculation .The problem is after addition and subtraction calculation I only get result or answer 0, .There are not a correct answer. I try to change the datatype of the variable to decimal and double but answer is still 0.
Here is my coding.
Private Sub btnadditionprice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadditionprice.Click
Dim sum6, sum9 As Decimal
sum6 = Val(Me.ItemPriceTextBox.Text) + Val(Me.txtadditionprice.Text)
[Code] .....
Answer which got is 0.000
I have made my calculator and it has 2 textboxes where the 2 numbers (or values go for addition and subtraction) are input and a label where the answer appears. There is other things on the page such as quit, clear etc thats all done but i have one query. I noticed while testing a problem occurs when only one number or value is put into a textbox and a command is hit. For example. one textbox (txtnumber1) has one number in it then i hit multiply and it says the error of course because its not programmed to deal with this (or divide by 0 of course) so i was wondering how i could make so when this happens a MsgBox appears saying a value must be in both boxes or when divded by zero is says something similar.
The line of code:
Private Sub blah blah blah...
If txtnumber1.Text = False Then MsgBox("Please Input Valid Value")
End Sub
I however have not been able to make it work.
I need to create a tiny calculator using the basic operators of Addition, Subtraction, Multiplication, and Division. My professor hasn't really covered much of this, so I'm not to sure how to create it.
View 6 RepliesI'm writing a program for my algebra students to practice integers.Stuff like....
3-6
-4 + (-5)
3(-4)
-15 � 3
etc.
I want to show an explanation and for the addition and subtraction, I want to show it on a number line. For example, if the problem is 3 - 7, the number line should show and arrow to that goes right to 3, and then left 7 units (starting from 3). Then the student can see that the answer is -4.I could probably do this with some string manipulation, but what would be the easiest way to do it in a picture format? Maybe a bitmap.
how to get the product using "+"(addition) and division using "-"(subtraction) and get it's remainder without using modulo division.
dim ctr as integer
for ctr=a to b
ctr=a+a
next ctr
i need help how to add odd numbers that are in my 6 textboxes collection and to see the result to label1 and how to add the textboxes that have numbers less than number 5.
View 4 RepliesWhat is wrong with this code? It is called in groups of four, and always seems to wind up with only two combinations:
[Code]...
It is returning random strings, but it seems to be returning them in a non-random order?
So I have code that will create a picture grid and then alignes them into a collage from left to right.
View 16 RepliesI was wondering how I could randomize a number between a given min/max and have it displayed in a label. And after it's been randomized in 2 different labels, I want to add these 2 integers (labels).
View 5 RepliesIn my "Select" statement I have this:
Int((Date()-dob)/365.25) AS Age
I would like to do the same thing in VB .NET code. I plan to do something like:
editBoxAge.Text = .......
dob would be stored in datePickerDob.Text
Below is my code in randomizing numbers in vb 2010 express edition. Error comes out stating that "AppendText is not declared. It may be inaccessible due to its protection level"..
Private Sub BtnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnAdd.Click
Dim x As Integer
Randomize()
For x = 0 To 8
TextBox1 = AppendText(Str(Int(Rnd() * 10)))
Next
[Code] .....
I am creating a hangman game for a class prject. I have done everything apart from randomising the word that is loaded in. I have tried a few different types of code but just can't seem to get it. I have tried this:
[Code]...
Basically I have 7 labels on a form that I randomize into numbers between 0 and 49. However some of the numbers repeat, like this 1,4,8,14,14,50,12. [Code]
View 2 RepliesBasically I have two textboxes.
Textbox1: "(Hey|Hi|Yo)! My name is (John|Linda|Carl)"
Textbox2: Blank
What I want to do is to press a button and transfer the contents of Textbox1 to Textbox2. However, I want it to randomize the result by randomly selecting between the words in the parentheses. Now of course, the contents of Textbox1 are subject to change at any time, so I can't just add code for "Hey", "Hi" and "Yo". I need some sort of system in place that will generate random results no matter what I put in Textbox1. So I guess I have to search the string for "(", note the location and then search for "|" to isolate the characters in between as one word or phrase. Then search for ")" to determine the end of the randomizing and continuing normally until the next "(".
Remember this from before?
Quote:
Since you are repeating same operation three times it is best to make a function for it.
CODE:
labels 1-6 are randomly generated numbers, text boxes 1-3 are the input boxes and the code above shows how if the answer in the textbox equals the labels added together, you win. This code works -
I have created labels 7-12 now, and textboxes 4-6. How can I extend this program so it has subtraction as well?
If this problem definition isn't detailed enough, let me know and I'll add more detail to this description.
if i have 2 textboxes and i want to do subtraction with textbox1 and textbox2.
The value inside textbox1 is "5 12 30 8 2"
The value inside textbox2 is "7 9 14 8 3"
May i know what can i do so that the result will be "-2 3 16 0 -1"???
This is in ASP.net iwth VB.I have a quiz project that I've been assigned for work.This quiz project contains two main SQL Databases it pulls the info from. First is a Quiz table, which contains three columns: QuizID (Pri Key), Title, Description. This is where I declare the quizzes, indicated by the QuizID (1, 2, 3....etc)
The second table is the Questions table, containing the following columns: QuestionsID (Pri Key), Title, Answer1, Answer2, Answer3, Answer4, Answer5, CorrectAnswer, QuestionOrder, QuizID....The QuizID in the Quesitons table matches the QuizID in the Quiz table.Thus for QuizID = 1, it consists of all the questions with the matching QuizID in the Questions table. The CorrectAnswer I want to assign a simple value (1, 2, 3...etc).I need a way to take a set of questions (based on the QuizID) put them in some sort of table and randomize them (or rather shuffle them) so that each time this quiz is taken, it pulls all questions randomly, but not repeating any)...I then want the code to pull the question and coorepsonding answers to pick from in a radiobuttonlist. However, It only needs to pull the number of answers. Example, a True/False will only have Answer1 and Answer2. The other Answers will have the NULL value in it.
There needs to then be a way to go through each one of these questions that have been placed in the table (in that random order) using a "next" button. When a question and possible answwers are displayed, I alaready have code to keep the answers in the session to grade it at the end (using correctAnswer and selected answer.I have no specific way to bind the data to the Database. I have used SQLDataSource to make other connections before, but I don't know if this is the best way.
randomizing picturebox location given four points example:i have 4 picture boxes. these boxes should be place at points (145, 190) (210, 190) (290, 190) (37, 190). this will display the pictureboxes at a horizontal line. i'm adding a functionality that when i press spacebar or click a button, these coordinates will be randomized and be assigned to my four pictureboxes just like in text twist but no animations.
View 7 Repliesi'm working on a simple 3D CAD to create complex 3D objects. This application uses:
1. Direct3D to render the objects
2.The methods contained in the Mesh class (such as Mesh.Box(...)) to create them
3.The Matrix class to apply some basic transformations (such as Translation or Rotation)
My issue is to do a boolean subtraction of a Mesh to another one to create a more complex Mesh, for example a Mesh with holes.
can I subtract a value from the value in the previous cell or cell above.I have created a stopwatch, and previous to using a datagridview, ive been using labels with this
If LapTimeLabel1.Text = "0:0.000" Then
LapTimeLabel1.Text = StopwatchLabel.Text
lapTime = DateTime.Now()
[code].....
i am creating here coding which use to substract number in database from textbox. In my coding i use textbox which receive number from user and it will subtract a number in database. For your info i am using UPDATE sql command for this operation . In the same time i also create table name InItem and have column name Itemquantity After i click the button i got an error InvalidOperationException was unhandled from my coding Here is my coding and please correct my coding if it have missing part. I also highlight which code give this error. Oh ya , is that my sql command for subtraction is correct? i also not sure cause it get it from internet.If my command if false please show me with correct command..
[Code]...