Finray
Hup! Dos, Tres, Cuatro
+2,629|6034|Catherine Black
Basically, at school I just started higher computing. We're learning Visual Basic 6.0, so I thought I'd get it on my computer too.. but the only Visual Basic I can get is 2008.

So yeah, it's a tad different. I'm trying to make a little percentage calculator, to figure out what percentage of 70 marks someone got in an exam. So I've got this; a text box, a button and a second text box. For the code of the button I have:

Code:

mark = Val(text1)
perc = (mark / 70) * 100
text2 = perc
This works fine on 6.0, but when I input this into 2008 I get "Mark is undefined" and "Perc is undefined".


So.. um.. halp?
https://i.imgur.com/qwWEP9F.png
SamBo:D
Banned
+236|5743|England
mark = Val(text2)
perc = (mark / 90) * 120
text2 = perc

try that!
bugz
Fission Mailed
+3,311|6558

I know nothing about Visual Basic but did you declare those two variables and did you give them an initial value?
Finray
Hup! Dos, Tres, Cuatro
+2,629|6034|Catherine Black
Yep, got 6.0, works fine on that
https://i.imgur.com/qwWEP9F.png
Vilham
Say wat!?
+580|7012|UK
you havent declared them. I havent used VB in a long time but if its anything like any other language you need to have something like:

int mark = 0;
int perc = 0;

somewhere at the top where your declarations are or if the scope they are in isn't important just above that code you wrote.

MSDN is something you should use btw, its very thorough

http://msdn.microsoft.com/en-us/library/ke6sh835(VS.80).aspx

Last edited by Vilham (2009-06-08 11:03:27)

Finray
Hup! Dos, Tres, Cuatro
+2,629|6034|Catherine Black
Okay now it won't take "/" as the command for divide. Or is it something else?
https://i.imgur.com/qwWEP9F.png
theDude5B
Cool member
+804|6996
what is your code now? i would think that you would need to make your variable a double if you are dividing and returning a decimal value.
Swan
The town bike
+54|5693
mark = Val(text1)
perc = (mark / 70) * 100
text2 = perc
Dim mark as Int32 = Int32.Parse(text1.Text)
Dim perc as Decimal = (mark / 70) * 100
text2.Text = perc.ToString()

Board footer

Privacy Policy - © 2024 Jeff Minard