Im a dumbarse procrastinator, and could use some help on stupid VB crap... *Edited with a new question*

Cuda1447

Lifer
Jul 26, 2002
11,757
0
71
*New Question*


Ok, so if I want to calculate the amount of change in dollars/quarters/nickles/pennies/dimes you would get back if you input a certain amount of pennies what would the best way to do it be?


The problem Im having is If I put in say 150 pennies, I have it calculate dollars first, but I need it to give me 1 dollar instead of 1.5 for my value, and then save the rest of it for my next calculation. I tried assigning integers and decimal values to these things, but that still gives me decimal places. What would I use to get rid of decimals?!? :(
 

Cuda1447

Lifer
Jul 26, 2002
11,757
0
71
What I tried doing was this...

Integer2 = Val (me.numberreg.text)

If Integer2 >= 50 then
me.totalowed.text = Val(me.numberreg.text) * 8
Else

Then whatever else I would need. I got the integer2 thing out of the book, but it says integer 2 is not defined. So how would I define it? And why couldn't I just use Val(me.numberreg.text) >= 50 instead of having to substitute integer2 in there? For some reason I can't figure out exactly how its supposed to go, aieieieiarg!
 

Cuda1447

Lifer
Jul 26, 2002
11,757
0
71
Originally posted by: Psycho14
:thumbsdown: with programming
:thumbsup: with Law Enforcement

I hear ya brother, problem is I HAVE to get all this crap done by noon tomorrow, or I = teh fail
 

z0mb13

Lifer
May 19, 2002
18,106
1
76
eh wtf isnt this REALLLYY easy?

I dont know VB but this is the idea:

totalPrice(int registrants) {

if(registrants > 12)
return registrants * 12
else
cout<<"registrants less than 12!"
}
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
Its in php, but it might help :

if($numb < 50)
{
$numb *=8 ;//also $numb = $numb * 8
echo $numb;
}
else
{
echo"You fvcked up";
}
 

Cuda1447

Lifer
Jul 26, 2002
11,757
0
71
Originally posted by: z0mb13
eh wtf isnt this REALLLYY easy?

I dont know VB but this is the idea:

totalPrice(int registrants) {

if(registrants > 12)
return registrants * 12
else
cout<<"registrants less than 12!"
}



I don't the idea behind it, I just dont know the code to write it. Thats what I can't figure out...



thx for the try AMD, but unfortunately that doesn't really help me any :(
 

xcript

Diamond Member
Apr 3, 2003
8,258
2
81
Originally posted by: Cuda1447
What I tried doing was this...

Integer2 = Val (me.numberreg.text)

If Integer2 >= 50 then
me.totalowed.text = Val(me.numberreg.text) * 8
Else
I haven't used VB for a long time (Perl owns me), but it'd be something like this I'd imagine:

dim foo as integer
foo = int(val(form1!text1.text))

if (foo<=50) then
form1!text2.text=int(foo*8)
else
form1!text2.text="n/a"
end if
 

Cuda1447

Lifer
Jul 26, 2002
11,757
0
71
Thx for the responses guys, Ive got the first part and it works. (Reading the book helps :) )

Dim intNumber As Integer
Dim intNumber2 As Integer
intNumber2 = 50
intNumber = Val(Me.NumberReg.Text)
If intNumber <= intNumber2 Then
Me.TotalOwedText.Text = intNumber * 8
Else



End If


Now I just have to figure out how to display a text message that says Your an idiot if they enter a value over 50. A bit more reading will probably help me figure that out
 

iamme

Lifer
Jul 21, 2001
21,058
3
0
Originally posted by: Cuda1447
Originally posted by: iamme
msgbox("you're an idiot")

Thats it, I don't have to create an actual message box or anything?

nope. just put that in your if/then block.

it'll make a windows default message box. there should be more options for msgbox in your book. but the basic one should do. try it out. that's the best way to remember programming.
 

Cuda1447

Lifer
Jul 26, 2002
11,757
0
71
Nevermind, I figured it out. I just used the text box I already had to display this message.


What I was trying to figure out was how to make a pop-up message, but I suppose I don't need one now :)
 

iamme

Lifer
Jul 21, 2001
21,058
3
0
Originally posted by: Cuda1447
Nevermind, I figured it out. I just used the text box I already had to display this message.


What I was trying to figure out was how to make a pop-up message, but I suppose I don't need one now :)

you could try the msgbox. it's very simple. maybe you'll impress your professor :p
 

Cuda1447

Lifer
Jul 26, 2002
11,757
0
71
Haha, I'll come back to it later if I have some time. From what I saw though it did look easy. Just everything is a bit tricky at first, this is my first time EVER even looking at this stuff, and I have to do 6 chapters and a quiz by noon tomorrow :)
 

KLin

Lifer
Feb 29, 2000
30,476
779
126
Dim i As Integer
i = InputBox("Please enter the number of registrants.")
If i >= 50 Then
MsgBox ("Please enter a number less then 50.")
Else
i = i * 8
MsgBox ("The total cost is $" &amp; i &amp; ".")
 

KLin

Lifer
Feb 29, 2000
30,476
779
126
use the Int function. It will drop the remainder. I believe it always rounds down though.