Jump to content

Need a Lil help with this program

Lexgium
Go to solution Solved by JamieF,

-snip-

-snip-

I'm bored so here's the code:

Public Class Form1    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim num1, num2, num3 As Integer        Randomize()        num1 = Int(Rnd() * 50) + 1        num2 = Int(Rnd() * 50) + 1        num3 = Int(Rnd() * 50) + 1        TextBox1.Text = num1.ToString()        TextBox2.Text = num2.ToString()        TextBox3.Text = num3.ToString()        If num1 + num2 = num3 Then            MessageBox.Show("Correct")        Else            MessageBox.Show("Incorrect")        End If    End SubEnd Class

Strange and kinda useless program though especially if you use numbers up to 50.

Well I was on class and had to do a program that in 3 textbox we introduce 3 numbers and the sum of 2 of these numbers it has to be the same as the other number a msgbox saying "correct" and "incorrect" if it is not

Link to comment
Share on other sites

Link to post
Share on other sites

//Place this in a button functionif (Number1+Number2 == Number3){ TextBox4.text = "Correct";}else{ TextBox4.text = "Incorrect";}

This should help a bit

 

EDIT: wait, first you have to make the strings from TextBox1 and 2 into ints. Google how to do this in your program.

@Lexgium

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

In psuedocode: 

if num1 + num2 == num3 then  display "Correct"else  display "incorrect"end

Not going to do you actual code for you. It's up to you to learn how to implement that

Link to comment
Share on other sites

Link to post
Share on other sites

it has to be random, my apologies didnt explained well, i meanif u introduce 30, 20 and 50, no mater in which one should say correct

 

in proper words the sum of any pair of numers

Link to comment
Share on other sites

Link to post
Share on other sites

it has to be random, my apologies didnt explained well, i meanif u introduce 30, 20 and 50, no mater in which one should say correct

 

in proper words the sum of any pair of numers

Qoute people when answering them.

I don't understand what you mean, could you explain again?

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

Qoute people when answering them.

I don't understand what you mean, could you explain again?

My apologies, well, when you run the program you introduce 3 different numbers, for example, 30, 20 and 50 you have to sum 2 of them and determine if the result is the 3rd number if it is the number the msg box says " correct"

@Minibois

Link to comment
Share on other sites

Link to post
Share on other sites

My apologies, well, when you run the program you introduce 3 different numbers, for example, 30, 20 and 50 you have to sum 2 of them and determine if the result is the 3rd number if it is the number the msg box says " correct"

So before you press the button, probably in the Start function or whatever (I don't do Visual Basic, so not sure) you just have to make 3 different  random numbers. 

And when a button is pressed, or just after that, you have to run code similar to mine or @MatazaNZ 's code.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

So before you press the button, probably in the Start function or whatever (I don't do Visual Basic, so not sure) you just have to make 3 different  random numbers. 

And when a button is pressed, or just after that, you have to run code similar to mine or @MatazaNZ 's code.

my code is similar to @MatazaNZ, but the sum has to be random, not the numbers,

Link to comment
Share on other sites

Link to post
Share on other sites

my code is similar to @MatazaNZ, but the sum has to be random, not the numbers,

num1 and num2 are random numbers, which have to be added up with each other and after that the code checks if it is the same as num3 (another random generated number).

After that num1 and num2 have to be added up and the code will check if num1+num2 equals num3.

If it does equal to the same, correct will be shown. If not, incorrect will be shown.

"We're all in this together, might as well be friends" Tom, Toonami.

 

mini eLiXiVy: my open source 65% mechanical PCB, a build log, PCB anatomy and discussing open source licenses: https://linustechtips.com/topic/1366493-elixivy-a-65-mechanical-keyboard-build-log-pcb-anatomy-and-how-i-open-sourced-this-project/

 

mini_cardboard: a 4% keyboard build log and how keyboards workhttps://linustechtips.com/topic/1328547-mini_cardboard-a-4-keyboard-build-log-and-how-keyboards-work/

Link to comment
Share on other sites

Link to post
Share on other sites

-snip-

-snip-

I'm bored so here's the code:

Public Class Form1    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim num1, num2, num3 As Integer        Randomize()        num1 = Int(Rnd() * 50) + 1        num2 = Int(Rnd() * 50) + 1        num3 = Int(Rnd() * 50) + 1        TextBox1.Text = num1.ToString()        TextBox2.Text = num2.ToString()        TextBox3.Text = num3.ToString()        If num1 + num2 = num3 Then            MessageBox.Show("Correct")        Else            MessageBox.Show("Incorrect")        End If    End SubEnd Class

Strange and kinda useless program though especially if you use numbers up to 50.

Link to comment
Share on other sites

Link to post
Share on other sites

I'm bored so here's the code:

Public Class Form1    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        Dim num1, num2, num3 As Integer        Randomize()        num1 = Int(Rnd() * 50) + 1        num2 = Int(Rnd() * 50) + 1        num3 = Int(Rnd() * 50) + 1        TextBox1.Text = num1.ToString()        TextBox2.Text = num2.ToString()        TextBox3.Text = num3.ToString()        If num1 + num2 = num3 Then            MessageBox.Show("Correct")        Else            MessageBox.Show("Incorrect")        End If    End SubEnd Class

Strange and kinda useless program though especially if you use numbers up to 50.

 

It was just a practice at class, thank you bot for answering, and thanks for the code

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×