Sign up to the jQuery Grid Subscription list.

division remainders and if statments ( Visual Basic General)

Original Post by alex905 at

The problem
alex905 :
hi i have a unsual question and im very bad at explaing things so please bear with me.

i have this code

'these are entered by the user
dim dig as single = 27
dim slt as single = 8

dim sltval as single

dim digval as single

If dig + slt = 0 Then

ElseIf dig = 0 Then
sltval = slt / 16
ElseIf slt = 0 Then
digval = dig / 16
' im not sure
End If

now im gonna try and explain it all. this code if to help a cusotmer buy a telephone system. he can buy a 16 port dig card, 8 port dig card, 16 port slt card or a combo 8 slt and 8 dig port card. the variables dig and slt are the amnount of ports. what i want to do with thse numbers is try and find out how many of each card the customer needs. still with me.

i got as far as dividing that amount of ports needed by the card with the most amount of ports (which i can do) then if their is a remainder above 8 add on another card if below 8 add on a 8 port card. but its not as easy as that as their are two types of port. so its fine if they only need one type of port whihc i have sort of covered in my code but if they have both types of port im lost. i know that if i use the figures i set in the variables above they would need.

27/16 = 1 and 11 remainder this means that i say the guy needs two 16 port dig cards. if the remander was below 8 i would say he needs one 16 port and one 8 port. but we have some slt ports aswell. so thats 8 whihc is les than or equle to 8 so one 8 port card is needed.

you still their. i dont expect anyone to help with this as it is long winded and overly complex. but my baic qustion is which division, how do you show whole numbers and the remanders not decimal places, and then put the remanders and whole numbers into differnet variables.

The Accepted solution

Dim x as integer = 10 Mod 3 ' Remainder
Dim y as integer = 10 \ 3 ' Whole number from division

MsgBox(x.ToString & " " & y.ToString)



Related Ads