![]() |
problem
i am trying to find a way to get the power of something for my program but i cant sem to find anything can anyone help
e.g 4 to the power of 2 i need to know the coding to get the power of please help |
Re: problem
Look for something called a POW() function. You could hard code it like this (in BASIC psuedo):
:
DIM number_1 AS INTEGER = 4 |
Re: problem
:
|
Re: problem
OpenLoop's solution also works in VB Classic (VB 6 and below). Just use the
^ operator. |
Re: problem
i have tried using the ^ to no effect
the program i am using requires to find the bmi (body mass index) of a person with the formula BMI = weight in kilograms / height in metres^2 i have tried using this to no effect please help i also need ther code to put the answer to 1 decimal place thanks edit: here is the code that i have been using usersbmi(Counter) = usersweight(Counter) / usersheight(Counter) ^ 2 i think that it may be working but justs needs to be rounded to the decimal place e.g 24=24.3 |
Re: problem
here is a copy of my program
:
Private Sub cmdok_Click()as you can see my main problem is the calculation :
Private Sub calculate_bmi(ByRef usersbmi() As Integer, usersweight() As Integer, usersheight() As Integer) |
Re: problem
What does 'to no effect' mean? are you getting an incorrect answer? can you give a sample output with expected results?
If you want a decimal point, you should define your variables as Float not Integer (not sure what VB's type for float) Also, Try using parenthesis to isolate the calculation. :
|
| All times are GMT -5. The time now is 6:23 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC