Programming help

iAnthony

Moderator
Moderator
Joined
Nov 15, 2013
Messages
590
Reaction score
3
Microsoft Visual Basic 2008

I am trying to create a program with only checkboxes but no buttons.
How do i program it so that when the checkbox is clicked it will execute an instruction?

I want to put all the checkboxes in one sub
Instead of
BtnWhatever.blahblah

What can i do to connect all the checkboxes in one sub?
 

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
I can't understand you do you mean, when you click any of the checkpoints to do the same thing?
You mean check, not click, right?
 

iAnthony

Moderator
Moderator
Joined
Nov 15, 2013
Messages
590
Reaction score
3
It is hard to explain in just words, i will post some screen shots to show you what I'm talking about.
 

iAnthony

Moderator
Moderator
Joined
Nov 15, 2013
Messages
590
Reaction score
3
i want to write a program that will add the prices of each click item. if i click shampoo and trim, the price should be $30 etc. how can i write a program to do this?
2vrsso6.jpg
 

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
iAnthony link said:
i want to write a program that will add the prices of each click item. if i click shampoo and trim, the price should be $30 etc. how can i write a program to do this?
2vrsso6.jpg

You can do it in 1000 ways.
first make a variable for each checkbox that will keep the price of the item.
Code:
float price1=15,price2=15,price3=5,price4=20;
Double click on each checkBox to open their events.
Make a function that will calculate the ammount of things checked.
Code:
void FainosagIsMyBoss()
{
float price=0;
if(checkBox1.Checked==true)
price+=price1;
if(checkBox2.Checked==true)
price+=price2;
if(checkBox3.Checked==true)
price+=price3;
if(checkBox4.Checked==true)
price+=price4;
label1.Text="Price: "+price.ToString()+"$";
}

And call this function on each of your 4 checkboxes
Code:
        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
FainosagIsMyBoss();
        }
 private void checkBox2_CheckedChanged(object sender, EventArgs e)
        {
FainosagIsMyBoss();
        }
 private void checkBox3_CheckedChanged(object sender, EventArgs e)
        {
FainosagIsMyBoss();
        }
 private void checkBox4_CheckedChanged(object sender, EventArgs e)
        {
FainosagIsMyBoss();
        }
 

iAnthony

Moderator
Moderator
Joined
Nov 15, 2013
Messages
590
Reaction score
3
can you write a simpler script for me?
like declaring the prices like
Dim Price1 As Integer =15
etc
then like
if Me.checkbox1.check = true then
price+= price1

then let the label display the current price
 

iAnthony

Moderator
Moderator
Joined
Nov 15, 2013
Messages
590
Reaction score
3
bro im a beginner xd.  :lol:

last question
can you create an OddNumbersSum application that displays the sum of the odd numbers from 1 to a maximum value entered by the user?

can you help me with this one?^
 

TheZeRots

Expert
Joined
Dec 21, 2013
Messages
1,247
Reaction score
1
iAnthony link said:
bro im a beginner xd.  :lol:

last question
can you create an OddNumbersSum application that displays the sum of the odd numbers from 1 to a maximum value entered by the user?

can you help me with this one?^
Man, I do this in Qbasic.
 

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
iAnthony link said:
bro im a beginner xd.  :lol:

last question
can you create an OddNumbersSum application that displays the sum of the odd numbers from 1 to a maximum value entered by the user?

can you help me with this one?^

I don't code in VB bro, is useless.
Learn C# is much easier and will help you a lot because languages like php java, javascript, c++ are almost the same, learning VB is useless..
 

iAnthony

Moderator
Moderator
Joined
Nov 15, 2013
Messages
590
Reaction score
3
Can you code it in c#, i have i will convert it to VB  :sweet_jesus:

The teacher is using VB, i cant do nothing about it  :red_eyes:
 

TheZeRots

Expert
Joined
Dec 21, 2013
Messages
1,247
Reaction score
1
Fainoșag link said:
[quote author=iAnthony link=topic=6717.msg38869#msg38869 date=1398270133]
bro im a beginner xd.  :lol:

last question
can you create an OddNumbersSum application that displays the sum of the odd numbers from 1 to a maximum value entered by the user?

can you help me with this one?^

I don't code in VB bro, is useless.
Learn C# is much easier and will help you a lot because languages like php java, javascript, c++ are almost the same, learning VB is useless..
[/quote]
Stop poisoning one's mind. If he is using VB, he is using VB, and no, there's nothing wrong about it; VB is for true beginners.
 

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
Grandpa Ze link said:
[quote author=Fainoșag link=topic=6717.msg38895#msg38895 date=1398276707]
[quote author=iAnthony link=topic=6717.msg38869#msg38869 date=1398270133]
bro im a beginner xd.  :lol:

last question
can you create an OddNumbersSum application that displays the sum of the odd numbers from 1 to a maximum value entered by the user?

can you help me with this one?^

I don't code in VB bro, is useless.
Learn C# is much easier and will help you a lot because languages like php java, javascript, c++ are almost the same, learning VB is useless..
[/quote]
Stop poisoning one's mind. If he is using VB, he is using VB, and no, there's nothing wrong about it; VB is for true beginners.
[/quote]

No, i also was a begginer (of course ) and C# helped me A LOT.

Anyways i don't understand what is your oddsumthing and wut u want, give me some ss or a better explanation and I will write what you have to do, something like in pseudocode.
 

iAnthony

Moderator
Moderator
Joined
Nov 15, 2013
Messages
590
Reaction score
3
Example- if i type 6 in the box, it should add the odd numbers between 1 and 6
i6vxio.jpg
 

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
You say that you type a number n in that textbox and you want that label to be
Sum of the Odd Numbers: 1+2+...n ?

So if you would type 6 the value would be 1+2+3+4+5+6 that is 21?
 

iAnthony

Moderator
Moderator
Joined
Nov 15, 2013
Messages
590
Reaction score
3
it should add all the odd numbers between 0 and the value in the textbox
if i type 6 it would add 1+3+5
 

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
You really need to learn first the basic of programming
http://thenewboston.org/list.php?cat=16

First do in console something like what you said, so you can understand what you are doing, when you are ok switch to Visual C#..

Just use a for that goes from 1 to that number, and the increment value is 2.. so for(int i=1; i<=n; i+=2)
and add your numbers..

Really you need to learn C++, after that C#, or you can start with C# in console..
 
Top