Can anyone help wiv some vb code

Associate
Joined
26 May 2004
Posts
103
Location
staffordshire
im doin an assignment 4 college nd it requires me 2 create a program that uses ratios to determine what 2 do next one of the ratios is that there needs to be 1 adult to every 4 children using the values in the text boxes it needs to work out if the ratio is met if it isnt then a message box is displayed. Im having loads of problems just trying to figure out the piece of code 4 it i would really appreciate it if some one can help me out. Thanks
 
Last edited:
If i understand correctly...

Code:
if ((option1/option2) <> 0.25) then
msgbox "Incorrect ratio"
end if

where option1 is the number of adults and option2 would be the number of kids.

Unless im missing something?
 
its not quite what im after im not using percentages it just needs 2 make sure that there is 1 adult 2 every 4 children so say if there were 5 children it would require 2 adults before it could do the next line of code if not it displays a message box its really hard 2 explain :confused:
 
It's even harder to follow when you use 2 in place of 'to' when trying to explain something to do with numerical data. :)
 
From what you've said then you want something like this

Code:
If Adults < Int((Children - 1)/4) + 1 Then
  Msgbox "Something"
Else
  Do Something Else
End If

PS Commas are your friend.
 
ok ive tried that code and it works in a way it does bring up a message box but it does for any combination of numbers it doesnt work out the ratios. But its a step further than i was
 
Back
Top Bottom